Merge pull request #54 from TheBlueMatt/main
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Thu, 4 Nov 2021 06:07:54 +0000 (06:07 +0000)
committerGitHub <noreply@github.com>
Thu, 4 Nov 2021 06:07:54 +0000 (06:07 +0000)
v0.0.103.0

350 files changed:
.github/workflows/build.yml
gen_type_mapping.py
genbindings.py
java_strings.py
src/main/java/org/ldk/batteries/ChannelManagerConstructor.java
src/main/java/org/ldk/batteries/NioPeerHandler.java
src/main/java/org/ldk/impl/bindings.java
src/main/java/org/ldk/structs/APIError.java
src/main/java/org/ldk/structs/AcceptChannel.java
src/main/java/org/ldk/structs/Access.java
src/main/java/org/ldk/structs/AnnouncementSignatures.java
src/main/java/org/ldk/structs/BackgroundProcessor.java
src/main/java/org/ldk/structs/Balance.java
src/main/java/org/ldk/structs/BaseSign.java
src/main/java/org/ldk/structs/BestBlock.java
src/main/java/org/ldk/structs/BuiltCommitmentTransaction.java
src/main/java/org/ldk/structs/ChainMonitor.java
src/main/java/org/ldk/structs/ChainParameters.java
src/main/java/org/ldk/structs/ChannelAnnouncement.java
src/main/java/org/ldk/structs/ChannelConfig.java
src/main/java/org/ldk/structs/ChannelCounterparty.java
src/main/java/org/ldk/structs/ChannelDetails.java
src/main/java/org/ldk/structs/ChannelFeatures.java
src/main/java/org/ldk/structs/ChannelHandshakeConfig.java
src/main/java/org/ldk/structs/ChannelHandshakeLimits.java
src/main/java/org/ldk/structs/ChannelInfo.java
src/main/java/org/ldk/structs/ChannelManager.java
src/main/java/org/ldk/structs/ChannelManagerPersister.java
src/main/java/org/ldk/structs/ChannelManagerReadArgs.java
src/main/java/org/ldk/structs/ChannelMessageHandler.java
src/main/java/org/ldk/structs/ChannelMonitor.java
src/main/java/org/ldk/structs/ChannelMonitorUpdate.java
src/main/java/org/ldk/structs/ChannelPublicKeys.java
src/main/java/org/ldk/structs/ChannelReestablish.java
src/main/java/org/ldk/structs/ChannelTransactionParameters.java
src/main/java/org/ldk/structs/ChannelUpdate.java
src/main/java/org/ldk/structs/ClosingSigned.java
src/main/java/org/ldk/structs/ClosingSignedFeeRange.java
src/main/java/org/ldk/structs/ClosingTransaction.java
src/main/java/org/ldk/structs/ClosureReason.java
src/main/java/org/ldk/structs/CommitmentSigned.java
src/main/java/org/ldk/structs/CommitmentTransaction.java
src/main/java/org/ldk/structs/CommitmentUpdate.java
src/main/java/org/ldk/structs/CommonBase.java
src/main/java/org/ldk/structs/CounterpartyChannelTransactionParameters.java
src/main/java/org/ldk/structs/CounterpartyForwardingInfo.java
src/main/java/org/ldk/structs/CustomMessageHandler.java
src/main/java/org/ldk/structs/CustomMessageReader.java
src/main/java/org/ldk/structs/DataLossProtect.java
src/main/java/org/ldk/structs/DecodeError.java
src/main/java/org/ldk/structs/DefaultRouter.java [new file with mode: 0644]
src/main/java/org/ldk/structs/DelayedPaymentOutputDescriptor.java
src/main/java/org/ldk/structs/Description.java
src/main/java/org/ldk/structs/DirectedChannelTransactionParameters.java
src/main/java/org/ldk/structs/DirectionalChannelInfo.java
src/main/java/org/ldk/structs/ErrorAction.java
src/main/java/org/ldk/structs/ErrorMessage.java
src/main/java/org/ldk/structs/ErroringMessageHandler.java
src/main/java/org/ldk/structs/Event.java
src/main/java/org/ldk/structs/ExpiryTime.java
src/main/java/org/ldk/structs/Fallback.java
src/main/java/org/ldk/structs/FilesystemPersister.java
src/main/java/org/ldk/structs/Filter.java
src/main/java/org/ldk/structs/FundingCreated.java
src/main/java/org/ldk/structs/FundingLocked.java
src/main/java/org/ldk/structs/FundingSigned.java
src/main/java/org/ldk/structs/GossipTimestampFilter.java
src/main/java/org/ldk/structs/HTLCOutputInCommitment.java
src/main/java/org/ldk/structs/HTLCUpdate.java
src/main/java/org/ldk/structs/HolderCommitmentTransaction.java
src/main/java/org/ldk/structs/IgnoringMessageHandler.java
src/main/java/org/ldk/structs/InMemorySigner.java
src/main/java/org/ldk/structs/Init.java
src/main/java/org/ldk/structs/InitFeatures.java
src/main/java/org/ldk/structs/InvalidShutdownScript.java
src/main/java/org/ldk/structs/Invoice.java
src/main/java/org/ldk/structs/InvoiceFeatures.java
src/main/java/org/ldk/structs/InvoicePayer.java [new file with mode: 0644]
src/main/java/org/ldk/structs/InvoiceSignature.java
src/main/java/org/ldk/structs/KeysInterface.java
src/main/java/org/ldk/structs/KeysManager.java
src/main/java/org/ldk/structs/LightningError.java
src/main/java/org/ldk/structs/LockableScore.java [new file with mode: 0644]
src/main/java/org/ldk/structs/MessageHandler.java
src/main/java/org/ldk/structs/MessageSendEvent.java
src/main/java/org/ldk/structs/MinFinalCltvExpiry.java
src/main/java/org/ldk/structs/MonitorEvent.java
src/main/java/org/ldk/structs/MonitorUpdateError.java
src/main/java/org/ldk/structs/MonitorUpdateId.java [new file with mode: 0644]
src/main/java/org/ldk/structs/NetAddress.java
src/main/java/org/ldk/structs/NetGraphMsgHandler.java
src/main/java/org/ldk/structs/NetworkGraph.java
src/main/java/org/ldk/structs/NetworkUpdate.java
src/main/java/org/ldk/structs/NodeAnnouncement.java
src/main/java/org/ldk/structs/NodeAnnouncementInfo.java
src/main/java/org/ldk/structs/NodeFeatures.java
src/main/java/org/ldk/structs/NodeId.java
src/main/java/org/ldk/structs/NodeInfo.java
src/main/java/org/ldk/structs/OpenChannel.java
src/main/java/org/ldk/structs/Option_AccessZ.java
src/main/java/org/ldk/structs/Option_C2Tuple_usizeTransactionZZ.java
src/main/java/org/ldk/structs/Option_CVec_NetAddressZZ.java
src/main/java/org/ldk/structs/Option_FilterZ.java
src/main/java/org/ldk/structs/Option_NetworkUpdateZ.java
src/main/java/org/ldk/structs/Option_TypeZ.java
src/main/java/org/ldk/structs/Option_u16Z.java
src/main/java/org/ldk/structs/Option_u32Z.java
src/main/java/org/ldk/structs/Option_u64Z.java
src/main/java/org/ldk/structs/OutPoint.java
src/main/java/org/ldk/structs/Payee.java [new file with mode: 0644]
src/main/java/org/ldk/structs/PayeePubKey.java
src/main/java/org/ldk/structs/Payer.java [new file with mode: 0644]
src/main/java/org/ldk/structs/PaymentError.java [new file with mode: 0644]
src/main/java/org/ldk/structs/PaymentId.java [deleted file]
src/main/java/org/ldk/structs/PaymentPurpose.java
src/main/java/org/ldk/structs/PaymentSendFailure.java
src/main/java/org/ldk/structs/PeerHandleError.java
src/main/java/org/ldk/structs/PeerManager.java
src/main/java/org/ldk/structs/Persist.java
src/main/java/org/ldk/structs/Ping.java
src/main/java/org/ldk/structs/Pong.java
src/main/java/org/ldk/structs/PositiveTimestamp.java
src/main/java/org/ldk/structs/PrivateRoute.java
src/main/java/org/ldk/structs/QueryChannelRange.java
src/main/java/org/ldk/structs/QueryShortChannelIds.java
src/main/java/org/ldk/structs/RawDataPart.java
src/main/java/org/ldk/structs/RawInvoice.java
src/main/java/org/ldk/structs/ReadOnlyNetworkGraph.java
src/main/java/org/ldk/structs/ReplyChannelRange.java
src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java
src/main/java/org/ldk/structs/Result_AcceptChannelDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_AnnouncementSignaturesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_BuiltCommitmentTransactionDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.java
src/main/java/org/ldk/structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.java
src/main/java/org/ldk/structs/Result_COption_TypeZDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_CResult_NetAddressu8ZDecodeErrorZ.java [deleted file]
src/main/java/org/ldk/structs/Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.java
src/main/java/org/ldk/structs/Result_CVec_CVec_u8ZZNoneZ.java
src/main/java/org/ldk/structs/Result_CVec_SignatureZNoneZ.java
src/main/java/org/ldk/structs/Result_CVec_u8ZPeerHandleErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelAnnouncementDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelConfigDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelFeaturesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelInfoDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelMonitorUpdateDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelPublicKeysDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelReestablishDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelTransactionParametersDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ChannelUpdateDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ClosingSignedDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ClosingSignedFeeRangeDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_CommitmentSignedDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_CommitmentTransactionDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_CounterpartyChannelTransactionParametersDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_DelayedPaymentOutputDescriptorDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_DescriptionCreationErrorZ.java
src/main/java/org/ldk/structs/Result_DirectionalChannelInfoDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ErrorMessageDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ExpiryTimeCreationErrorZ.java
src/main/java/org/ldk/structs/Result_FundingCreatedDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_FundingLockedDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_FundingSignedDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_GossipTimestampFilterDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_HTLCOutputInCommitmentDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_HTLCUpdateDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_HolderCommitmentTransactionDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_InMemorySignerDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_InitDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_InitFeaturesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_InvoiceFeaturesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_InvoiceNoneZ.java
src/main/java/org/ldk/structs/Result_InvoiceSemanticErrorZ.java
src/main/java/org/ldk/structs/Result_InvoiceSignOrCreationErrorZ.java
src/main/java/org/ldk/structs/Result_LockedChannelMonitorNoneZ.java
src/main/java/org/ldk/structs/Result_NetAddressDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NetAddressu8Z.java [deleted file]
src/main/java/org/ldk/structs/Result_NetworkGraphDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NodeAnnouncementDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NodeAnnouncementInfoDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NodeFeaturesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NodeIdDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NodeInfoDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_NoneAPIErrorZ.java
src/main/java/org/ldk/structs/Result_NoneChannelMonitorUpdateErrZ.java
src/main/java/org/ldk/structs/Result_NoneErrorZ.java
src/main/java/org/ldk/structs/Result_NoneLightningErrorZ.java
src/main/java/org/ldk/structs/Result_NoneMonitorUpdateErrorZ.java
src/main/java/org/ldk/structs/Result_NoneNoneZ.java
src/main/java/org/ldk/structs/Result_NonePaymentSendFailureZ.java
src/main/java/org/ldk/structs/Result_NonePeerHandleErrorZ.java
src/main/java/org/ldk/structs/Result_NoneSemanticErrorZ.java
src/main/java/org/ldk/structs/Result_OpenChannelDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_OutPointDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_PayeeDecodeErrorZ.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Result_PayeePubKeyErrorZ.java
src/main/java/org/ldk/structs/Result_PaymentIdDecodeErrorZ.java [deleted file]
src/main/java/org/ldk/structs/Result_PaymentIdPaymentErrorZ.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Result_PaymentIdPaymentSendFailureZ.java
src/main/java/org/ldk/structs/Result_PaymentSecretAPIErrorZ.java
src/main/java/org/ldk/structs/Result_PingDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_PongDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_PositiveTimestampCreationErrorZ.java
src/main/java/org/ldk/structs/Result_PrivateRouteCreationErrorZ.java
src/main/java/org/ldk/structs/Result_PublicKeyErrorZ.java
src/main/java/org/ldk/structs/Result_QueryChannelRangeDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_QueryShortChannelIdsDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_RecoverableSignatureNoneZ.java
src/main/java/org/ldk/structs/Result_ReplyChannelRangeDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ReplyShortChannelIdsEndDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_RevokeAndACKDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_RouteDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_RouteHintDecodeErrorZ.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Result_RouteHintHopDecodeErrorZ.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Result_RouteHopDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_RouteLightningErrorZ.java
src/main/java/org/ldk/structs/Result_RouteParametersDecodeErrorZ.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Result_RoutingFeesDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_SecretKeyErrorZ.java
src/main/java/org/ldk/structs/Result_ShutdownDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ShutdownScriptDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_ShutdownScriptInvalidShutdownScriptZ.java
src/main/java/org/ldk/structs/Result_SiPrefixNoneZ.java
src/main/java/org/ldk/structs/Result_SignDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_SignatureNoneZ.java
src/main/java/org/ldk/structs/Result_SignedRawInvoiceNoneZ.java
src/main/java/org/ldk/structs/Result_SpendableOutputDescriptorDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_StaticPaymentOutputDescriptorDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_StringErrorZ.java
src/main/java/org/ldk/structs/Result_TransactionNoneZ.java
src/main/java/org/ldk/structs/Result_TrustedClosingTransactionNoneZ.java
src/main/java/org/ldk/structs/Result_TrustedCommitmentTransactionNoneZ.java
src/main/java/org/ldk/structs/Result_TxCreationKeysDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_TxCreationKeysErrorZ.java
src/main/java/org/ldk/structs/Result_TxOutAccessErrorZ.java
src/main/java/org/ldk/structs/Result_UnsignedChannelAnnouncementDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UnsignedChannelUpdateDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UnsignedNodeAnnouncementDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UpdateAddHTLCDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UpdateFailHTLCDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UpdateFailMalformedHTLCDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UpdateFeeDecodeErrorZ.java
src/main/java/org/ldk/structs/Result_UpdateFulfillHTLCDecodeErrorZ.java
src/main/java/org/ldk/structs/Result__u832APIErrorZ.java
src/main/java/org/ldk/structs/Result_boolLightningErrorZ.java
src/main/java/org/ldk/structs/Result_boolPeerHandleErrorZ.java
src/main/java/org/ldk/structs/RetryAttempts.java [new file with mode: 0644]
src/main/java/org/ldk/structs/RevokeAndACK.java
src/main/java/org/ldk/structs/Route.java
src/main/java/org/ldk/structs/RouteHint.java
src/main/java/org/ldk/structs/RouteHintHop.java
src/main/java/org/ldk/structs/RouteHop.java
src/main/java/org/ldk/structs/RouteParameters.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Router.java [new file with mode: 0644]
src/main/java/org/ldk/structs/RoutingFees.java
src/main/java/org/ldk/structs/RoutingMessageHandler.java
src/main/java/org/ldk/structs/Score.java
src/main/java/org/ldk/structs/Scorer.java
src/main/java/org/ldk/structs/ScoringParameters.java [new file with mode: 0644]
src/main/java/org/ldk/structs/Sha256.java
src/main/java/org/ldk/structs/Shutdown.java
src/main/java/org/ldk/structs/ShutdownScript.java
src/main/java/org/ldk/structs/Sign.java
src/main/java/org/ldk/structs/SignOrCreationError.java
src/main/java/org/ldk/structs/SignedRawInvoice.java
src/main/java/org/ldk/structs/SocketDescriptor.java
src/main/java/org/ldk/structs/SpendableOutputDescriptor.java
src/main/java/org/ldk/structs/StaticPaymentOutputDescriptor.java
src/main/java/org/ldk/structs/TrustedCommitmentTransaction.java
src/main/java/org/ldk/structs/TwoTuple_BlockHashChannelManagerZ.java
src/main/java/org/ldk/structs/TwoTuple_BlockHashChannelMonitorZ.java
src/main/java/org/ldk/structs/TwoTuple_OutPointScriptZ.java
src/main/java/org/ldk/structs/TwoTuple_PaymentHashPaymentIdZ.java
src/main/java/org/ldk/structs/TwoTuple_PaymentHashPaymentSecretZ.java
src/main/java/org/ldk/structs/TwoTuple_PublicKeyTypeZ.java
src/main/java/org/ldk/structs/TwoTuple_SignatureCVec_SignatureZZ.java
src/main/java/org/ldk/structs/TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ.java
src/main/java/org/ldk/structs/TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ.java
src/main/java/org/ldk/structs/TwoTuple_u32ScriptZ.java
src/main/java/org/ldk/structs/TwoTuple_u32TxOutZ.java
src/main/java/org/ldk/structs/TwoTuple_usizeTransactionZ.java
src/main/java/org/ldk/structs/TxCreationKeys.java
src/main/java/org/ldk/structs/Type.java
src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java
src/main/java/org/ldk/structs/UnsignedChannelUpdate.java
src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java
src/main/java/org/ldk/structs/UpdateAddHTLC.java
src/main/java/org/ldk/structs/UpdateFailHTLC.java
src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java
src/main/java/org/ldk/structs/UpdateFee.java
src/main/java/org/ldk/structs/UpdateFulfillHTLC.java
src/main/java/org/ldk/structs/UserConfig.java
src/main/java/org/ldk/structs/UtilMethods.java
src/main/java/org/ldk/structs/Watch.java
src/main/java/org/ldk/structs/WatchedOutput.java
src/main/jni/bindings.c
src/main/jni/bindings.c.body
src/main/jni/org_ldk_impl_bindings.h
src/main/jni/org_ldk_impl_bindings_LDKPaymentError.h [new file with mode: 0644]
src/test/java/org/ldk/HumanObjectPeerTest.java
src/test/java/org/ldk/PeerTest.java
ts/bindings.c
ts/bindings.c.body
ts/bindings.ts
ts/structs/ChainMonitor.ts
ts/structs/ChannelManager.ts
ts/structs/ClosingTransaction.ts
ts/structs/DefaultRouter.ts [new file with mode: 0644]
ts/structs/Event.ts
ts/structs/InvalidShutdownScript.ts
ts/structs/Invoice.ts
ts/structs/InvoicePayer.ts [new file with mode: 0644]
ts/structs/LockableScore.ts [new file with mode: 0644]
ts/structs/MinFinalCltvExpiry.ts
ts/structs/MonitorEvent.ts
ts/structs/MonitorUpdateError.ts
ts/structs/MonitorUpdateId.ts [new file with mode: 0644]
ts/structs/NetGraphMsgHandler.ts
ts/structs/Payee.ts [new file with mode: 0644]
ts/structs/PayeePubKey.ts
ts/structs/Payer.ts [new file with mode: 0644]
ts/structs/PaymentError.ts [new file with mode: 0644]
ts/structs/PaymentId.ts [deleted file]
ts/structs/PaymentSendFailure.ts
ts/structs/PeerManager.ts
ts/structs/Persist.ts
ts/structs/Result_CResult_NetAddressu8ZDecodeErrorZ.ts [deleted file]
ts/structs/Result_NetAddressu8Z.ts [deleted file]
ts/structs/Result_PayeeDecodeErrorZ.ts [new file with mode: 0644]
ts/structs/Result_PaymentIdDecodeErrorZ.ts [deleted file]
ts/structs/Result_PaymentIdPaymentErrorZ.ts [new file with mode: 0644]
ts/structs/Result_PaymentIdPaymentSendFailureZ.ts
ts/structs/Result_RouteHintDecodeErrorZ.ts [new file with mode: 0644]
ts/structs/Result_RouteHintHopDecodeErrorZ.ts [new file with mode: 0644]
ts/structs/Result_RouteParametersDecodeErrorZ.ts [new file with mode: 0644]
ts/structs/Result_ShutdownScriptInvalidShutdownScriptZ.ts
ts/structs/RetryAttempts.ts [new file with mode: 0644]
ts/structs/Route.ts
ts/structs/RouteHint.ts
ts/structs/RouteHintHop.ts
ts/structs/RouteParameters.ts [new file with mode: 0644]
ts/structs/Router.ts [new file with mode: 0644]
ts/structs/Score.ts
ts/structs/Scorer.ts
ts/structs/ScoringParameters.ts [new file with mode: 0644]
ts/structs/TwoTuple_PaymentHashPaymentIdZ.ts
ts/structs/UtilMethods.ts
typescript_strings.py

index 885f0b83fa79e0fd39a4db16768aa82ca11cfacf..4bdd6dbfb1216b219de65d24bd6fff2e357df47c 100644 (file)
@@ -17,7 +17,7 @@ jobs:
         run: |
           apt-get update
           apt-get -y dist-upgrade
-          apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm
+          apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
       - name: Checkout source code
         uses: actions/checkout@v2
         with:
@@ -35,7 +35,7 @@ jobs:
           cd ..
           git clone https://github.com/lightningdevkit/ldk-c-bindings
           cd ldk-c-bindings
-          git checkout 0.0.102
+          git checkout 0.0.103
       - name: Rebuild C bindings without STD for WASM
         run: |
           cd ldk-c-bindings
@@ -60,7 +60,16 @@ jobs:
       - name: Checkout latest MacOS binaries
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-          git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
+          echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
+          SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+          curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+          mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          tar xvvf ../../bins-snapshot.tgz
+          mv ldk-java-bins-*/* ./
+          rm -r ldk-java-bins-*
+          cd ../..
           mkdir -p src/main/resources/
           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/
       - name: Build Java/TS Release Bindings
@@ -76,24 +85,23 @@ jobs:
       - name: Check latest library and jars are in bins repo
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-          rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"*.jar
-          rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Linux*.nativelib
-          cp src/main/resources/liblightningjni_Linux-amd64.nativelib "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cp ldk-java-sources.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cp ldk-java.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cp ldk-java-classes.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cp ldk-java-javadoc.jar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cd ldk-java-bins
+          mkdir ldk-java-bins/new/
+          cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
+          cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
           # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism
-          git checkout "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-leaktracking.jar"
-          if ! git diff --exit-code; then
-            mv "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"* ./
-            git checkout "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
+          cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/
+          cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
+          cp ldk-java-sources.jar ldk-java-bins/new/
+          cp ldk-java.jar ldk-java-bins/new/
+          cp ldk-java-classes.jar ldk-java-bins/new/
+          cp ldk-java-javadoc.jar ldk-java-bins/new/
+          cd ldk-java-bins
+          if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
             apt-get -y install diffoscope
-            diffoscope ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
-            diffoscope ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
-            diffoscope ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
-            diffoscope ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
+            diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
+            diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
+            diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
+            diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
             exit 1
           fi
       - name: Run Java Tests against built release jar
@@ -153,9 +161,31 @@ jobs:
           cd ..
           git clone https://github.com/lightningdevkit/ldk-c-bindings
           cd ldk-c-bindings
-          git checkout 0.0.102
+          git checkout 0.0.103
       - name: Checkout Android AAR binaries and artifacts
-        run: git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
+        run: |
+          # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
+          export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
+          echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
+          SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+          curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+
+          ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
+          SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+          curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+
+          mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          tar xvvf ../../bins-snapshot.tgz
+          mv ldk-java-bins-*/* ./
+          rm -r ldk-java-bins-*
+
+          mkdir -p ../android-artifacts
+          cd ../android-artifacts
+          tar xvvf ../../android-snapshot.tgz
+          mv ldk-java-bins-*/* ./
+          rm -r ldk-java-bins-*
       - name: Build Android aar
         run: |
           . $HOME/.cargo/env
@@ -167,14 +197,9 @@ jobs:
       - name: Check latest library and jars are in bins repo
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-          rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
-          cp LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-          cd ldk-java-bins
-          if ! git diff --exit-code; then
-            mv "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar" ./
-            git checkout "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
+          if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
             apt-get -y install diffoscope
-            diffoscope LDK-release.aar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
+            diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
             exit 1
           fi
 
@@ -218,7 +243,7 @@ jobs:
           cd ..
           git clone https://github.com/lightningdevkit/ldk-c-bindings
           cd ldk-c-bindings
-          git checkout 0.0.102
+          git checkout 0.0.103
       - name: Rebuild C bindings with upstream clang, and check the sample app builds + links
         run: |
           cd ldk-c-bindings
@@ -238,7 +263,15 @@ jobs:
       - name: Checkout latest Linux binaries
         run: |
           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-          git clone --depth 1 https://git.bitcoin.ninja/ldk-java-bins
+          echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
+          SNAPSHOT_LINK="$(wget -O /dev/stdout "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
+          wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
+          mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
+          tar xvvf ../../bins-snapshot.tgz
+          mv ldk-java-bins-*/* ./
+          cd ../..
           mkdir -p src/main/resources/
           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
       - name: Build Java/TS Release Bindings
@@ -280,11 +313,9 @@ jobs:
         run: |
           if [ "${{ matrix.platform }}" = "macos-11" ]; then
             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
-            rm "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-{x86_64,aarch64}.nativelib
-            cp src/main/resources/liblightningjni_MacOSX-*.nativelib "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"
-            cd ldk-java-bins
             # Sadly, OSX binaries are not currently deterministic, more debugging is needed.
-            #git diff --exit-code
+            diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib || echo
+            diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib || echo
           fi
       - name: Run Java Tests against release bins
         run: |
index c8064da102393465bebde71ff96a76d76ac173d0..81bb0f99b8ebcaa5236073fa627514c8d224a212 100644 (file)
@@ -16,10 +16,21 @@ class TypeMappingGenerator:
 
     def map_type(self, fn_arg, print_void, ret_arr_len, is_free, holds_ref):
         ty_info = self.java_c_types(fn_arg, ret_arr_len)
-        mapped_info = self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref)
+        mapped_info = self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref, False)
         return mapped_info
 
-    def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_ref):
+    def map_nullable_type(self, fn_arg, print_void, ret_arr_len, is_free, holds_ref):
+        ty_info = self.java_c_types(fn_arg, ret_arr_len)
+        mapped_info = self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref, True)
+        return mapped_info
+
+    def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_ref, is_nullable):
+        mapped_info = self._do_map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref, is_nullable)
+        if is_nullable:
+            mapped_info.nullable = True
+        return mapped_info
+
+    def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_ref, is_nullable):
         if ty_info.c_ty == "void":
             if not print_void:
                 return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
@@ -85,7 +96,7 @@ class TypeMappingGenerator:
                     # function itself, resulting in a segfault. Thus, we manually check and ensure we don't clone for
                     # ChannelMonitors inside of vecs.
                     ty_info.subty.requires_clone = False
-                subty = self.map_type_with_info(ty_info.subty, False, None, is_free, holds_ref)
+                subty = self.map_type_with_info(ty_info.subty, False, None, is_free, holds_ref, False)
                 arg_conv = ty_info.rust_obj + " " + arr_name + "_constr;\n"
                 pf = ""
                 if ty_info.is_ptr:
@@ -127,32 +138,43 @@ class TypeMappingGenerator:
                 if ty_info.is_ptr:
                     arg_conv += "\n\t" + arr_name + "_ptr = &" + arr_name + "_constr;\n}"
 
-                ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "")
+                if is_nullable:
+                    ret_conv = (ty_info.rust_obj + " *" + arr_name + "_var_ptr = ", "")
+                else:
+                    ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "")
                 if subty.ret_conv is None:
                     ret_conv = ("DUMMY", "DUMMY")
                 else:
-                    ret_conv = (ret_conv[0], ";\n" + ty_info.c_ty + " " + arr_name + "_arr = " + self.consts.create_native_arr_call(arr_name + "_var." + arr_len, ty_info) + ";\n")
+                    ret_conv = (ret_conv[0], ";\n" + ty_info.c_ty + " " + arr_name + "_arr = NULL;\n")
+                    indent = ""
+                    if is_nullable:
+                        ret_conv = (ret_conv[0], ret_conv[1] + "if (" + arr_name + " != NULL) {\n")
+                        ret_conv = (ret_conv[0], ret_conv[1] + "\t" + ty_info.rust_obj + " " + arr_name + "_var = *" + arr_name + "_var_ptr;\n")
+                        indent = "\t"
+                    ret_conv = (ret_conv[0], ret_conv[1] + indent + arr_name + "_arr = " + self.consts.create_native_arr_call(arr_name + "_var." + arr_len, ty_info) + ";\n")
                     get_ptr_call = self.consts.get_native_arr_ptr_call(ty_info)
                     if get_ptr_call is not None:
-                        ret_conv = (ret_conv[0], ret_conv[1] + subty.c_ty + " *" + arr_name + "_arr_ptr = " + get_ptr_call[0] + arr_name + "_arr" + get_ptr_call[1] + ";\n")
-                    ret_conv = (ret_conv[0], ret_conv[1] + "for (size_t " + idxc + " = 0; " + idxc + " < " + arr_name + "_var." + arr_len + "; " + idxc + "++) {\n")
-                    ret_conv = (ret_conv[0], ret_conv[1] + "\t" + subty.ret_conv[0].replace("\n", "\n\t"))
-                    ret_conv = (ret_conv[0], ret_conv[1] + arr_name + "_var." + ty_info.arr_access + "[" + idxc + "]" + subty.ret_conv[1].replace("\n", "\n\t"))
+                        ret_conv = (ret_conv[0], ret_conv[1] + indent + subty.c_ty + " *" + arr_name + "_arr_ptr = " + get_ptr_call[0] + arr_name + "_arr" + get_ptr_call[1] + ";\n")
+                    ret_conv = (ret_conv[0], ret_conv[1] + indent + "for (size_t " + idxc + " = 0; " + idxc + " < " + arr_name + "_var." + arr_len + "; " + idxc + "++) {\n")
+                    ret_conv = (ret_conv[0], ret_conv[1] + indent + "\t" + subty.ret_conv[0].replace("\n", "\n\t" + indent))
+                    ret_conv = (ret_conv[0], ret_conv[1] + indent + arr_name + "_var." + ty_info.arr_access + "[" + idxc + "]" + subty.ret_conv[1].replace("\n", "\n\t" + indent) + "\n")
                     if get_ptr_call is not None:
-                        ret_conv = (ret_conv[0], ret_conv[1] + "\n\t" + arr_name + "_arr_ptr[" + idxc + "] = " + subty.ret_conv_name + ";\n}")
+                        ret_conv = (ret_conv[0], ret_conv[1] + indent + "\t" + arr_name + "_arr_ptr[" + idxc + "] = " + subty.ret_conv_name + ";\n" + indent + "}\n")
                     else:
-                        ret_conv = (ret_conv[0], ret_conv[1] + "\n\t" + self.consts.get_native_arr_entry_call(ty_info, arr_name + "_arr", idxc, subty.ret_conv_name) + ";\n}")
+                        ret_conv = (ret_conv[0], ret_conv[1] + indent + "\t" + self.consts.get_native_arr_entry_call(ty_info, arr_name + "_arr", idxc, subty.ret_conv_name) + ";\n" + indent + "}\n")
                     cleanup = self.consts.release_native_arr_ptr_call(ty_info, arr_name + "_arr", arr_name + "_arr_ptr")
                     if cleanup is not None:
-                        ret_conv = (ret_conv[0], ret_conv[1] + "\n" + cleanup + ";")
-                if not holds_ref:
-                    # XXX: The commented if's are a bit smarter freeing, but we need to be a nudge smarter still
-                    # Note that we don't drop the full vec here - we're passing ownership to java (or have cloned) or free'd by now!
-                    ret_conv = (ret_conv[0], ret_conv[1] + "\nFREE(" + arr_name + "_var." + ty_info.arr_access + ");")
-                    #if subty.rust_obj is not None and subty.rust_obj in self.opaque_structs:
-                    #    ret_conv = (ret_conv[0], ret_conv[1] + "\nFREE(" + arr_name + "_var." + ty_info.arr_access + ");")
-                    #else:
-                    #    ret_conv = (ret_conv[0], ret_conv[1] + "\n" + ty_info.rust_obj.replace("LDK", "") + "_free(" + arr_name + "_var);")
+                        ret_conv = (ret_conv[0], ret_conv[1] + indent + cleanup + ";")
+                    if not holds_ref and not is_nullable:
+                        # XXX: The commented if's are a bit smarter freeing, but we need to be a nudge smarter still
+                        # Note that we don't drop the full vec here - we're passing ownership to java (or have cloned) or free'd by now!
+                        ret_conv = (ret_conv[0], ret_conv[1] + "\n" + indent + "FREE(" + arr_name + "_var." + ty_info.arr_access + ");")
+                        #if subty.rust_obj is not None and subty.rust_obj in self.opaque_structs:
+                        #    ret_conv = (ret_conv[0], ret_conv[1] + "\nFREE(" + arr_name + "_var." + ty_info.arr_access + ");")
+                        #else:
+                        #    ret_conv = (ret_conv[0], ret_conv[1] + "\n" + ty_info.rust_obj.replace("LDK", "") + "_free(" + arr_name + "_var);")
+                    if is_nullable:
+                        ret_conv = (ret_conv[0], ret_conv[1] + "\n}")
 
                 to_hu_conv = None
                 to_hu_conv_name = None
@@ -185,6 +207,7 @@ class TypeMappingGenerator:
                     arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = arg_conv_cleanup,
                     ret_conv = ret_conv, ret_conv_name = arr_name + "_arr", to_hu_conv = to_hu_conv, to_hu_conv_name = to_hu_conv_name, from_hu_conv = from_hu_conv)
         elif ty_info.java_ty == "String":
+            assert not is_nullable
             if not is_free:
                 arg_conv = "LDKStr " + ty_info.var_name + "_conv = " + self.consts.str_ref_to_c_call(ty_info.var_name) + ";"
                 arg_conv_name = ty_info.var_name + "_conv"
@@ -221,6 +244,7 @@ class TypeMappingGenerator:
                     arg_conv = None, arg_conv_name = "arg", arg_conv_cleanup = None,
                     ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 8", to_hu_conv_name = None, from_hu_conv = None)
         elif ty_info.is_native_primitive:
+            assert not is_nullable
             return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
                 arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
                 ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
@@ -254,20 +278,27 @@ class TypeMappingGenerator:
                             "// Thus, after this call, " + ty_info.var_name + " is reset to null and is now a dummy object.\n" + ty_info.var_name + ".ptr = 0")
 
                 opaque_ret_conv_suf = ";\n"
+                opaque_ret_conv_suf += "uint64_t " + ty_info.var_name + "_ref = 0;\n"
+                indent = ""
+                if is_nullable:
+                    opaque_ret_conv_suf += "if ((uint64_t)" + ty_info.var_name + "_var.inner > 4096) {\n"
+                    indent = "\t"
                 if not holds_ref and ty_info.is_ptr and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: # is_ptr, not holds_ref implies passing a pointed-to value to java, which needs copied
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");\n"
+                    opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");\n"
                 elif not holds_ref and ty_info.is_ptr:
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "// Warning: we may need a move here but no clone is available for " + ty_info.rust_obj + "\n"
+                    opaque_ret_conv_suf += indent + "// Warning: we may need a move here but no clone is available for " + ty_info.rust_obj + "\n"
 
-                opaque_ret_conv_suf = opaque_ret_conv_suf + "CHECK((((uint64_t)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n"
-                opaque_ret_conv_suf = opaque_ret_conv_suf + "CHECK((((uint64_t)&" + ty_info.var_name + "_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.\n"
+                opaque_ret_conv_suf += indent + "CHECK((((uint64_t)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n"
+                opaque_ret_conv_suf += indent + "CHECK((((uint64_t)&" + ty_info.var_name + "_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.\n"
                 if holds_ref:
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "uint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_var.inner & ~1;"
+                    opaque_ret_conv_suf += indent + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_var.inner & ~1;"
                 else:
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "uint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_var.inner;\n"
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "if (" + ty_info.var_name + "_var.is_owned) {\n"
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "\t" + ty_info.var_name + "_ref |= 1;\n"
-                    opaque_ret_conv_suf = opaque_ret_conv_suf + "}"
+                    opaque_ret_conv_suf += indent + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_var.inner;\n"
+                    opaque_ret_conv_suf += indent + "if (" + ty_info.var_name + "_var.is_owned) {\n"
+                    opaque_ret_conv_suf += indent + "\t" + ty_info.var_name + "_ref |= 1;\n"
+                    opaque_ret_conv_suf += indent + "}"
+                if is_nullable:
+                    opaque_ret_conv_suf += "\n}"
 
                 to_hu_conv_sfx = ""
                 if not ty_info.is_ptr or holds_ref:
@@ -289,6 +320,7 @@ class TypeMappingGenerator:
                         to_hu_conv_name = ty_info.var_name + "_hu_conv",
                         from_hu_conv = from_hu_conv)
 
+            assert not is_nullable
             if not ty_info.is_ptr:
                 if ty_info.rust_obj in self.unitary_enums:
                     (ret_pfx, ret_sfx) = self.consts.c_unitary_enum_to_native_call(ty_info)
@@ -299,9 +331,11 @@ class TypeMappingGenerator:
                         arg_conv_cleanup = None,
                         ret_conv = (ty_info.c_ty + " " + ty_info.var_name + "_conv = " + ret_pfx, ret_sfx + ";"),
                         ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
-                base_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)(((uint64_t)" + ty_info.var_name + ") & ~1);"
+                base_conv = "void* " + ty_info.var_name + "_ptr = (void*)(((uint64_t)" + ty_info.var_name + ") & ~1);\n"
+                base_conv += "CHECK_ACCESS(" + ty_info.var_name + "_ptr);\n"
+                base_conv += ty_info.rust_obj + " " + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)(" + ty_info.var_name + "_ptr);"
                 if ty_info.rust_obj in self.trait_structs:
-                    ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_ret =MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_ret = ", ";")
+                    ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_ret = ", ";")
                     if holds_ref:
                         if (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns:
                             ret_conv = (ret_conv[0] + ty_info.rust_obj.replace("LDK", "") + "_clone(&", ");")
@@ -352,14 +386,8 @@ class TypeMappingGenerator:
                     ret_conv = ("uint64_t " + ty_info.var_name + "_ref = ((uint64_t)&", ") | 1;")
                     if not holds_ref:
                         ret_conv = (ty_info.rust_obj + " *" + ty_info.var_name + "_copy = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n", "")
-                        if ty_info.requires_clone == True: # Set in object array mapping
-                            if (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns:
-                                ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&", ");\n")
-                            else:
-                                ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", "; // Warning: We likely need to clone here, but no clone is available for " + ty_inf.rust_obj + "\n")
-                        else:
-                            ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", ";\n")
-                        ret_conv = (ret_conv[0], ret_conv[1] + "uint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_copy;")
+                        ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", "")
+                        ret_conv = (ret_conv[0], ";\nuint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_copy;")
                     return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
                         arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
                         ret_conv = ret_conv, ret_conv_name = ty_info.var_name + "_ref",
@@ -382,12 +410,12 @@ class TypeMappingGenerator:
                     ret_conv_name = "((uint64_t)" + ty_info.var_name + "_conv)"
                     if holds_ref:
                         # If we're trying to return a ref, we have to clone.
-                        # We just blindly assume its implemented and let the compiler fail if its not.
-                        ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_conv = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_conv = ", ";")
                         if (ty_info.rust_obj.replace("LDK", "") + "_clone") not in self.clone_fns:
-                            ret_conv = (ret_conv[0], ret_conv[1] + "\n// Warning: we really need to clone here, but no clone is available for " + ty_info.rust_obj)
+                            ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_conv = &", "")
+                            ret_conv = (ret_conv[0], ";\n// Warning: we really need to clone here, but no clone is available for " + ty_info.rust_obj)
                             ret_conv_name += " | 1"
                         else:
+                            ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_conv = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_conv = ", ";")
                             ret_conv = (ret_conv[0], ret_conv[1] + "\n*" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + "_conv);")
                     else:
                         ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_conv = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_conv = ", ";")
@@ -438,7 +466,9 @@ class TypeMappingGenerator:
                         from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", from_hu_sfx))
                 elif ty_info.rust_obj in self.trait_structs:
                     if ty_info.nonnull_ptr:
-                        arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)(((uint64_t)" + ty_info.var_name + ") & ~1);"
+                        arg_conv = "void* " + ty_info.var_name + "_ptr = (void*)(((uint64_t)" + ty_info.var_name + ") & ~1);\n"
+                        arg_conv += "if (!(" + ty_info.var_name + " & 1)) { CHECK_ACCESS(" + ty_info.var_name + "_ptr); }\n"
+                        arg_conv += ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + "_ptr;"
                         arg_conv_name = ty_info.var_name + "_conv"
                     else:
                         # We map Option<Trait> as *mut Trait, which we can differentiate from &Trait by the NONNULL_PTR annotation.
@@ -446,7 +476,9 @@ class TypeMappingGenerator:
                         arg_conv = ty_info.rust_obj + " *" + ty_info.var_name + "_conv_ptr = NULL;\n"
                         arg_conv += "if (" + ty_info.var_name + " != 0) {\n"
                         arg_conv += "\t" + ty_info.rust_obj + " " + ty_info.var_name + "_conv;\n"
-                        arg_conv += "\t" + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)(((uint64_t)" + ty_info.var_name + ") & ~1);"
+                        arg_conv += "void* " + ty_info.var_name + "_ptr = (void*)(((uint64_t)" + ty_info.var_name + ") & ~1);\n"
+                        arg_conv += "CHECK_ACCESS(" + ty_info.var_name + "_ptr);\n"
+                        arg_conv += "\t" + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)" + ty_info.var_name + "_ptr;"
                         arg_conv += self.consts.trait_struct_inc_refcnt(ty_info).replace("\n", "\n\t")
                         arg_conv += "\n\t" + ty_info.var_name + "_conv_ptr = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n"
                         arg_conv += "\t*" + ty_info.var_name + "_conv_ptr = " + ty_info.var_name + "_conv;\n"
@@ -464,7 +496,8 @@ class TypeMappingGenerator:
                     else:
                         return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
                             arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = None,
-                            ret_conv = ("uint64_t ret_" + ty_info.var_name + " = (uint64_t)", ";"), ret_conv_name = "ret_" + ty_info.var_name,
+                            ret_conv = ("// WARNING: This object doesn't live past this scope, needs clone!\nuint64_t ret_" + ty_info.var_name + " = ((uint64_t)", ") | 1;"),
+                            ret_conv_name = "ret_" + ty_info.var_name,
                             to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");\nret_hu_conv.ptrs_to.add(this);",
                             to_hu_conv_name = "ret_hu_conv",
                             from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")"))
index 1aa2c8ee3729b50f06c154cf4430c7e23779cc77..c46644b8ee746eb76a801db18c4bf2c44eff2f1c 100755 (executable)
@@ -410,11 +410,11 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
             expected_struct = "LDK" + struct_meth
             struct_meth_name = method_name[len(struct_meth) + 1 if len(struct_meth) != 0 else 0:].strip("_")
 
-        return_type_info = type_mapping_generator.map_type(method_return_type.strip() + " ret", True, ret_arr_len, False, force_holds_ref)
-
         (params_nullable, ret_nullable) = doc_to_params_ret_nullable(doc_comment)
         if ret_nullable:
-            return_type_info.nullable = True
+            return_type_info = type_mapping_generator.map_nullable_type(method_return_type.strip() + " ret", True, ret_arr_len, False, force_holds_ref)
+        else:
+            return_type_info = type_mapping_generator.map_type(method_return_type.strip() + " ret", True, ret_arr_len, False, force_holds_ref)
 
         argument_types = []
         default_constructor_args = {}
@@ -423,13 +423,15 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
         args_known = True
 
         for argument_index, argument in enumerate(method_arguments):
-            argument_conversion_info = type_mapping_generator.map_type(argument, False, None, is_free, True)
-            if argument_index == 0 and argument_conversion_info.java_hu_ty == struct_meth:
+            arg_ty = type_mapping_generator.java_c_types(argument, None)
+            argument_conversion_info = None
+            if argument_index == 0 and arg_ty.java_hu_ty == struct_meth:
+                argument_conversion_info = type_mapping_generator.map_type_with_info(arg_ty, False, None, is_free, True, False)
                 takes_self = True
                 if argument_conversion_info.ty_info.is_ptr:
                     takes_self_ptr = True
-            elif argument_conversion_info.arg_name in params_nullable:
-                argument_conversion_info.nullable = True
+            elif arg_ty.var_name in params_nullable:
+                argument_conversion_info = type_mapping_generator.map_type_with_info(arg_ty, False, None, is_free, True, True)
                 if argument_conversion_info.arg_conv is not None and "Warning" in argument_conversion_info.arg_conv:
                     arg_ty_info = java_c_types(argument, None)
                     print("WARNING: Remapping argument " + arg_ty_info.var_name + " of function " + method_name + " to a reference")
@@ -443,8 +445,11 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
                     print("    It may or may not actually be a reference, but its the simplest mapping option")
                     print("    and also the only use of this code today.")
                     arg_ty_info.requires_clone = False
-                    argument_conversion_info = type_mapping_generator.map_type_with_info(arg_ty_info, False, None, is_free, True)
+                    argument_conversion_info = type_mapping_generator.map_type_with_info(arg_ty_info, False, None, is_free, True, True)
+                    assert argument_conversion_info.nullable
                     assert argument_conversion_info.arg_conv is not None and "Warning" not in argument_conversion_info.arg_conv
+            else:
+                argument_conversion_info = type_mapping_generator.map_type_with_info(arg_ty, False, None, is_free, True, False)
 
             if argument_conversion_info.arg_conv is not None and "Warning" in argument_conversion_info.arg_conv:
                 if argument_conversion_info.rust_obj in constructor_fns:
@@ -554,10 +559,12 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
                     enum_var_lines = union_enum_items["LDK" + variant_name]
                     for idx, (field, field_docs) in enumerate(enum_var_lines):
                         if idx != 0 and idx < len(enum_var_lines) - 2 and field.strip() != "":
-                            field_ty = type_mapping_generator.map_type(field.strip(' ;'), False, None, False, True)
+                            field_ty = type_mapping_generator.java_c_types(field.strip(' ;'), None)
                             if field_docs is not None and doc_to_field_nullable(field_docs):
-                                field_ty.nullable = True
-                            fields.append((field_ty, field_docs))
+                                field_conv = type_mapping_generator.map_type_with_info(field_ty, False, None, False, True, True)
+                            else:
+                                field_conv = type_mapping_generator.map_type_with_info(field_ty, False, None, False, True, False)
+                            fields.append((field_conv, field_docs))
                     enum_variants.append(ComplexEnumVariantInfo(variant_name, fields, False))
                 elif camel_to_snake(variant_name) in inline_enum_variants:
                     # TODO: If we ever have a rust enum Variant(Option<Struct>) we need to pipe
@@ -595,22 +602,25 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
                     ret_ty_info = type_mapping_generator.map_type("void", True, None, False, False)
                     field_fns.append(TraitMethInfo("cloned", False, ret_ty_info, [], fn_docs))
                 else:
-                    ret_ty_info = type_mapping_generator.map_type(fn_line.group(2).strip() + " ret", True, None, False, False)
-                    is_const = fn_line.group(4) is not None
                     (nullable_params, ret_nullable) = doc_to_params_ret_nullable(fn_docs)
                     if ret_nullable:
                         assert False # This isn't yet handled on the Java side
                         ret_ty_info.nullable = True
+                        ret_ty_info = type_mapping_generator.map_nullable_type(fn_line.group(2).strip() + " ret", True, None, False, False)
+                    else:
+                        ret_ty_info = type_mapping_generator.map_type(fn_line.group(2).strip() + " ret", True, None, False, False)
+                    is_const = fn_line.group(4) is not None
 
                     arg_tys = []
                     for idx, arg in enumerate(fn_line.group(5).split(',')):
                         if arg == "":
                             continue
-                        arg_conv_info = type_mapping_generator.map_type(arg, True, None, False, False)
-                        if arg_conv_info.arg_name in nullable_params:
+                        arg_ty_info = type_mapping_generator.java_c_types(arg, None)
+                        if arg_ty_info.var_name in nullable_params:
                             # Types that are actually null instead of all-0s aren't yet handled on the Java side:
-                            assert arg_conv_info.rust_obj == "LDKPublicKey"
-                            arg_conv_info.nullable = True
+                            arg_conv_info = type_mapping_generator.map_type_with_info(arg_ty_info, True, None, False, False, True)
+                        else:
+                            arg_conv_info = type_mapping_generator.map_type_with_info(arg_ty_info, True, None, False, False, False)
                         arg_tys.append(arg_conv_info)
                     field_fns.append(TraitMethInfo(fn_line.group(3), is_const, ret_ty_info, arg_tys, fn_docs))
 
@@ -724,39 +734,14 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
             out_java_struct.write("\t}\n\n")
 
     def map_tuple(struct_name, field_lines):
-        out_java.write("\tpublic static native long " + struct_name + "_new(")
-        write_c(consts.c_fn_ty_pfx + consts.ptr_c_ty + " " + consts.c_fn_name_define_pfx(struct_name + "_new", len(field_lines) > 3))
         human_ty = struct_name.replace("LDKC2Tuple", "TwoTuple").replace("LDKC3Tuple", "ThreeTuple")
         with open(f"{sys.argv[3]}/structs/{human_ty}{consts.file_ext}", "w") as out_java_struct:
             out_java_struct.write(consts.map_tuple(struct_name))
             ty_list = []
             for idx, (line, _) in enumerate(field_lines):
                 if idx != 0 and idx < len(field_lines) - 2:
-                    ty_info = java_c_types(line.strip(';'), None)
-                    if idx != 1:
-                        out_java.write(", ")
-                        write_c(", ")
-                    e = chr(ord('a') + idx - 1)
-                    out_java.write(ty_info.java_ty + " " + e)
-                    write_c(ty_info.c_ty + " " + e)
-                    ty_list.append(ty_info)
+                    ty_list.append(java_c_types(line.strip(';'), None))
             tuple_types[struct_name] = (ty_list, struct_name)
-            out_java.write(");\n")
-            write_c(") {\n")
-            write_c("\t" + struct_name + "* ret = MALLOC(sizeof(" + struct_name + "), \"" + struct_name + "\");\n")
-            for idx, (line, _) in enumerate(field_lines):
-                if idx != 0 and idx < len(field_lines) - 2:
-                    ty_info = type_mapping_generator.map_type(line.strip(';'), False, None, False, False)
-                    e = chr(ord('a') + idx - 1)
-                    if ty_info.arg_conv is not None:
-                        write_c("\t" + ty_info.arg_conv.replace("\n", "\n\t"))
-                        write_c("\n\tret->" + e + " = " + ty_info.arg_conv_name + ";\n")
-                    else:
-                        write_c("\tret->" + e + " = " + e + ";\n")
-                    if ty_info.arg_conv_cleanup is not None:
-                        write_c("\t//TODO: Really need to call " + ty_info.arg_conv_cleanup + " here\n")
-            write_c("\treturn (uint64_t)ret;\n")
-            write_c("}\n")
 
         # Map virtual getter functions
         for idx, (line, _) in enumerate(field_lines):
index 1e7ba997083b055cbe04113be14ddb0851b6d90d..15c3ac4783ad222aef4647d40fcf1ebb6bec7204 100644 (file)
@@ -18,8 +18,8 @@ class Consts:
         )
 
         self.to_hu_conv_templates = dict(
-            ptr = '{human_type} {var_name}_hu_conv = new {human_type}(null, {var_name});',
-            default = '{human_type} {var_name}_hu_conv = new {human_type}(null, {var_name});'
+            ptr = '{human_type} {var_name}_hu_conv = null; if ({var_name} < 0 || {var_name} > 4096) { {var_name}_hu_conv = new {human_type}(null, {var_name}); }',
+            default = '{human_type} {var_name}_hu_conv = null; if ({var_name} < 0 || {var_name} > 4096) { {var_name}_hu_conv = new {human_type}(null, {var_name}); }'
         )
 
         self.bindings_header = """package org.ldk.impl;
@@ -115,7 +115,7 @@ import java.util.LinkedList;
 class CommonBase {
        long ptr;
        LinkedList<Object> ptrs_to = new LinkedList();
-       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; }
+       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 4096; this.ptr = ptr; }
 }
 """
 
@@ -161,7 +161,8 @@ void __attribute__((constructor)) spawn_stderr_redirection() {
 
         if not DEBUG or sys.platform == "darwin":
             self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
+#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
+#define CHECK_ACCESS(p)
 """
         if not DEBUG:
             self.c_file_pfx += """#define DO_ASSERT(a) (void)(a)
@@ -282,7 +283,7 @@ static void alloc_freed(void* ptr) {
        while (it->ptr != ptr) {
                p = it; it = it->next;
                if (it == NULL) {
-                       DEBUG_PRINT("Tried to free unknown pointer %p at:\\n", ptr);
+                       DEBUG_PRINT("ERROR: Tried to free unknown pointer %p at:\\n", ptr);
                        void* bt[BT_MAX];
                        int bt_len = backtrace(bt, BT_MAX);
                        backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
@@ -297,7 +298,7 @@ static void alloc_freed(void* ptr) {
        __real_free(it);
 }
 static void FREE(void* ptr) {
-       if ((uint64_t)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
+       if ((uint64_t)ptr <= 4096) return; // Rust loves to create pointers to the NULL page for dummys
        alloc_freed(ptr);
        __real_free(ptr);
 }
@@ -318,6 +319,24 @@ void __wrap_free(void* ptr) {
        __real_free(ptr);
 }
 
+static void CHECK_ACCESS(void* ptr) {
+       DO_ASSERT(!pthread_mutex_lock(&allocation_mtx));
+       allocation* it = allocation_ll;
+       while (it->ptr != ptr) {
+               it = it->next;
+               if (it == NULL) {
+                       DEBUG_PRINT("ERROR: Tried to access unknown pointer %p at:\\n", ptr);
+                       void* bt[BT_MAX];
+                       int bt_len = backtrace(bt, BT_MAX);
+                       backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
+                       DEBUG_PRINT("\\n\\n");
+                       DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx));
+                       return; // addrsan should catch and print more info than we have
+               }
+       }
+       DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx));
+}
+
 void* __real_realloc(void* ptr, size_t newlen);
 void* __wrap_realloc(void* ptr, size_t len) {
        if (ptr != NULL) alloc_freed(ptr);
@@ -1258,7 +1277,7 @@ import javax.annotation.Nullable;
                     out_java_struct += (info.arg_name)
             out_java_struct += (");\n")
             if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long":
-                out_java_struct += "\t\tif (ret >= 0 && ret < 1024) { return null; }\n"
+                out_java_struct += "\t\tif (ret >= 0 && ret <= 4096) { return null; }\n"
 
             if return_type_info.to_hu_conv is not None:
                 if not takes_self:
index 8cf57536a5a0d58d94ab46dec31bca3f1755c865..0e68a947141c9ed3a1bab449816cdab77f20d4f8 100644 (file)
@@ -45,13 +45,22 @@ public class ChannelManagerConstructor {
      * A NioPeerHandler which manages a background thread to handle socket events and pass them to the peer_manager.
      */
     public final NioPeerHandler nio_peer_handler;
+    /**
+     * If a `NetworkGraph` is provided to the constructor *and* a `LockableScore` is provided to
+        * `chain_sync_completed`, this will be non-null after `chain_sync_completed` returns.
+        *
+     * It should be used to send payments instead of doing so directly via the `channel_manager`.
+        *
+     * When payments are made through this, they are automatically retried and the provided Scorer
+     * will be updated with payment failure data.
+     */
+    @Nullable public InvoicePayer payer;
 
     private final ChainMonitor chain_monitor;
-
+    @Nullable private final NetworkGraph net_graph;
+    @Nullable private final NetGraphMsgHandler graph_msg_handler;
     private final Logger logger;
 
-    public final @Nullable NetGraphMsgHandler router;
-
     /**
      * Deserializes a channel manager and a set of channel monitors from the given serialized copies and interface implementations
      *
@@ -61,7 +70,7 @@ public class ChannelManagerConstructor {
      */
     public ChannelManagerConstructor(byte[] channel_manager_serialized, byte[][] channel_monitors_serialized,
                                      KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor, @Nullable Filter filter,
-                                     @Nullable NetGraphMsgHandler router,
+                                     @Nullable NetworkGraph net_graph,
                                      BroadcasterInterface tx_broadcaster, Logger logger) throws InvalidSerializedDataException {
         final IgnoringMessageHandler no_custom_messages = IgnoringMessageHandler.of();
         final ChannelMonitor[] monitors = new ChannelMonitor[channel_monitors_serialized.length];
@@ -84,14 +93,18 @@ public class ChannelManagerConstructor {
         this.channel_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_b();
         this.channel_manager_latest_block_hash = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_a();
         this.chain_monitor = chain_monitor;
-        this.router = router;
         this.logger = logger;
         byte[] random_data = keys_interface.get_secure_random_bytes();
-        if (router != null) {
-            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(),
+        this.net_graph = net_graph;
+        if (net_graph != null) {
+            //TODO: We really need to expose the Access here to let users prevent DoS issues
+            this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
+            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
+                    graph_msg_handler.as_RoutingMessageHandler(),
                     keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
         } else {
-            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), (IgnoringMessageHandler.of()).as_RoutingMessageHandler(),
+            this.graph_msg_handler = null;
+            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), no_custom_messages.as_RoutingMessageHandler(),
                     keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
         }
         NioPeerHandler nio_peer_handler = null;
@@ -113,23 +126,27 @@ public class ChannelManagerConstructor {
      */
     public ChannelManagerConstructor(Network network, UserConfig config, byte[] current_blockchain_tip_hash, int current_blockchain_tip_height,
                                      KeysInterface keys_interface, FeeEstimator fee_estimator, ChainMonitor chain_monitor,
-                                     @Nullable NetGraphMsgHandler router,
+                                     @Nullable NetworkGraph net_graph,
                                      BroadcasterInterface tx_broadcaster, Logger logger) {
         final IgnoringMessageHandler no_custom_messages = IgnoringMessageHandler.of();
         channel_monitors = new TwoTuple_BlockHashChannelMonitorZ[0];
         channel_manager_latest_block_hash = null;
         this.chain_monitor = chain_monitor;
-        this.router = router;
         BestBlock block = BestBlock.of(current_blockchain_tip_hash, current_blockchain_tip_height);
         ChainParameters params = ChainParameters.of(network, block);
         channel_manager = ChannelManager.of(fee_estimator, chain_monitor.as_Watch(), tx_broadcaster, logger, keys_interface, config, params);
         this.logger = logger;
         byte[] random_data = keys_interface.get_secure_random_bytes();
-        if (router != null) {
-            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(),
+        this.net_graph = net_graph;
+        if (net_graph != null) {
+            //TODO: We really need to expose the Access here to let users prevent DoS issues
+            this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
+            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
+                    graph_msg_handler.as_RoutingMessageHandler(),
                     keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
         } else {
-            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), (IgnoringMessageHandler.of()).as_RoutingMessageHandler(),
+            this.graph_msg_handler = null;
+            this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), no_custom_messages.as_RoutingMessageHandler(),
                     keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
         }
         NioPeerHandler nio_peer_handler = null;
@@ -159,16 +176,23 @@ public class ChannelManagerConstructor {
      * This also spawns a background thread which will call the appropriate methods on the provided
      * EventHandler as required.
      */
-    public void chain_sync_completed(EventHandler event_handler) {
+    public void chain_sync_completed(EventHandler event_handler, @Nullable LockableScore scorer) {
         if (background_processor != null) { return; }
         for (TwoTuple_BlockHashChannelMonitorZ monitor: channel_monitors) {
             this.chain_monitor.as_Watch().watch_channel(monitor.get_b().get_funding_txo().get_a(), monitor.get_b());
         }
+        org.ldk.structs.EventHandler ldk_handler = org.ldk.structs.EventHandler.new_impl(event_handler::handle_event);
+        if (this.net_graph != null && scorer != null) {
+            Router router = DefaultRouter.of(net_graph, logger).as_Router();
+            this.payer = InvoicePayer.of(this.channel_manager.as_Payer(), router, scorer, this.logger, ldk_handler, RetryAttempts.of(3));
+assert this.payer != null;
+            ldk_handler = this.payer.as_EventHandler();
+        }
+
         background_processor = BackgroundProcessor.start(org.ldk.structs.ChannelManagerPersister.new_impl(channel_manager -> {
             event_handler.persist_manager(channel_manager.write());
             return Result_NoneErrorZ.ok();
-        }), org.ldk.structs.EventHandler.new_impl(event_handler::handle_event),
-        this.chain_monitor, this.channel_manager, this.router, this.peer_manager, this.logger);
+        }), ldk_handler, this.chain_monitor, this.channel_manager, this.graph_msg_handler, this.peer_manager, this.logger);
     }
 
     /**
index bf111729115492ba7e3c94c26645290b000794d3..afe728b059c482cc35983051ab3f72ed998b0e99 100644 (file)
@@ -174,10 +174,11 @@ public class NioPeerHandler {
                                 if (chan == null) continue;
                                 try {
                                     Peer peer = setup_socket(chan);
+                                    peer.key = chan.register(this.selector, SelectionKey.OP_READ, peer);
                                     Result_NonePeerHandleErrorZ res = this.peer_manager.new_inbound_connection(peer.descriptor);
-                                    if (res instanceof Result_NonePeerHandleErrorZ.Result_NonePeerHandleErrorZ_OK) {
-                                        peer.key = chan.register(this.selector, SelectionKey.OP_READ, peer);
-                                    }
+                                    if (res instanceof Result_NonePeerHandleErrorZ.Result_NonePeerHandleErrorZ_Err) {
+                                                                               peer.descriptor.disconnect_socket();
+                                                                       }
                                 } catch (IOException ignored) { }
                             }
                             continue; // There is no attachment so the rest of the loop is useless
@@ -273,14 +274,17 @@ public class NioPeerHandler {
             throw new IOException("Timed out");
         }
         Peer peer = setup_socket(chan);
+        do_selector_action(() -> peer.key = chan.register(this.selector, SelectionKey.OP_READ, peer));
         Result_CVec_u8ZPeerHandleErrorZ res = this.peer_manager.new_outbound_connection(their_node_id, peer.descriptor);
         if (res instanceof  Result_CVec_u8ZPeerHandleErrorZ.Result_CVec_u8ZPeerHandleErrorZ_OK) {
             byte[] initial_bytes = ((Result_CVec_u8ZPeerHandleErrorZ.Result_CVec_u8ZPeerHandleErrorZ_OK) res).res;
             if (chan.write(ByteBuffer.wrap(initial_bytes)) != initial_bytes.length) {
+                peer.descriptor.disconnect_socket();
+                this.peer_manager.socket_disconnected(peer.descriptor);
                 throw new IOException("We assume TCP socket buffer is at least a single packet in length");
             }
-            do_selector_action(() -> peer.key = chan.register(this.selector, SelectionKey.OP_READ, peer));
         } else {
+            peer.descriptor.disconnect_socket();
             throw new IOException("LDK rejected outbound connection. This likely shouldn't ever happen.");
         }
     }
index 0a875796348fda2059a9601e201e4495c3f5abd4..99e579fb65f776153dd181cd830b91d4166330b6 100644 (file)
@@ -153,6 +153,10 @@ public class bindings {
        public static native boolean LDKCResult_RouteDecodeErrorZ_result_ok(long arg);
        public static native long LDKCResult_RouteDecodeErrorZ_get_ok(long arg);
        public static native long LDKCResult_RouteDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_RouteParametersDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_RouteParametersDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_RouteParametersDecodeErrorZ_get_err(long arg);
+       public static native long LDKCVec_RouteHintZ_new(long[] elems);
        public static class LDKCOption_u64Z {
                private LDKCOption_u64Z() {}
                public final static class Some extends LDKCOption_u64Z {
@@ -166,15 +170,23 @@ public class bindings {
        }
        static { LDKCOption_u64Z.init(); }
        public static native LDKCOption_u64Z LDKCOption_u64Z_ref_from_ptr(long ptr);
+       public static native boolean LDKCResult_PayeeDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_PayeeDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_PayeeDecodeErrorZ_get_err(long arg);
+       public static native long LDKCVec_RouteHintHopZ_new(long[] elems);
+       public static native boolean LDKCResult_RouteHintDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_RouteHintDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_RouteHintDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_RouteHintHopDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_RouteHintHopDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_RouteHintHopDecodeErrorZ_get_err(long arg);
        public static native long LDKCVec_ChannelDetailsZ_new(long[] elems);
-       public static native long LDKCVec_RouteHintZ_new(long[] elems);
        public static native boolean LDKCResult_RouteLightningErrorZ_result_ok(long arg);
        public static native long LDKCResult_RouteLightningErrorZ_get_ok(long arg);
        public static native long LDKCResult_RouteLightningErrorZ_get_err(long arg);
        public static native boolean LDKCResult_TxOutAccessErrorZ_result_ok(long arg);
        public static native long LDKCResult_TxOutAccessErrorZ_get_ok(long arg);
        public static native AccessError LDKCResult_TxOutAccessErrorZ_get_err(long arg);
-       public static native long LDKC2Tuple_usizeTransactionZ_new(long a, byte[] b);
        // uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple);
        public static native long C2Tuple_usizeTransactionZ_get_a(long tuple);
        // struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple);
@@ -193,6 +205,15 @@ public class bindings {
                        public long commitment_tx_confirmed;
                        CommitmentTxConfirmed(long commitment_tx_confirmed) { this.commitment_tx_confirmed = commitment_tx_confirmed; }
                }
+               public final static class UpdateCompleted extends LDKMonitorEvent {
+                       public long funding_txo;
+                       public long monitor_update_id;
+                       UpdateCompleted(long funding_txo, long monitor_update_id) { this.funding_txo = funding_txo; this.monitor_update_id = monitor_update_id; }
+               }
+               public final static class UpdateFailed extends LDKMonitorEvent {
+                       public long update_failed;
+                       UpdateFailed(long update_failed) { this.update_failed = update_failed; }
+               }
                static native void init();
        }
        static { LDKMonitorEvent.init(); }
@@ -397,6 +418,12 @@ public class bindings {
        public static native boolean LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(long arg);
        public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(long arg);
        public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_ScoringParametersDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_ScoringParametersDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_ScoringParametersDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_ScorerDecodeErrorZ_result_ok(long arg);
+       public static native long LDKCResult_ScorerDecodeErrorZ_get_ok(long arg);
+       public static native long LDKCResult_ScorerDecodeErrorZ_get_err(long arg);
        public static native boolean LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(long arg);
        public static native long LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(long arg);
        public static native long LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(long arg);
@@ -409,7 +436,6 @@ public class bindings {
        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);
        // struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_SignatureCVec_SignatureZZ_get_a(long tuple);
        // struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple);
@@ -487,7 +513,6 @@ public class bindings {
        public static native boolean LDKCResult_TransactionNoneZ_result_ok(long arg);
        public static native byte[] LDKCResult_TransactionNoneZ_get_ok(long arg);
        public static native void LDKCResult_TransactionNoneZ_get_err(long arg);
-       public static native long LDKC2Tuple_BlockHashChannelMonitorZ_new(byte[] a, long b);
        // struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_BlockHashChannelMonitorZ_get_a(long tuple);
        // struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple);
@@ -496,9 +521,6 @@ public class bindings {
        public static native boolean LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(long arg);
        public static native long[] LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(long arg);
        public static native IOError LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(long arg);
-       public static native boolean LDKCResult_PaymentIdDecodeErrorZ_result_ok(long arg);
-       public static native long LDKCResult_PaymentIdDecodeErrorZ_get_ok(long arg);
-       public static native long LDKCResult_PaymentIdDecodeErrorZ_get_err(long arg);
        public static class LDKCOption_u16Z {
                private LDKCOption_u16Z() {}
                public final static class Some extends LDKCOption_u16Z {
@@ -565,24 +587,25 @@ public class bindings {
                        AllFailedRetrySafe(long[] all_failed_retry_safe) { this.all_failed_retry_safe = all_failed_retry_safe; }
                }
                public final static class PartialFailure extends LDKPaymentSendFailure {
-                       public long[] partial_failure;
-                       PartialFailure(long[] partial_failure) { this.partial_failure = partial_failure; }
+                       public long[] results;
+                       public long failed_paths_retry;
+                       public byte[] payment_id;
+                       PartialFailure(long[] results, long failed_paths_retry, byte[] payment_id) { this.results = results; this.failed_paths_retry = failed_paths_retry; this.payment_id = payment_id; }
                }
                static native void init();
        }
        static { LDKPaymentSendFailure.init(); }
        public static native LDKPaymentSendFailure LDKPaymentSendFailure_ref_from_ptr(long ptr);
        public static native boolean LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(long arg);
-       public static native long LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(long arg);
+       public static native byte[] LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(long arg);
        public static native long LDKCResult_PaymentIdPaymentSendFailureZ_get_err(long arg);
        public static native boolean LDKCResult_NonePaymentSendFailureZ_result_ok(long arg);
        public static native void LDKCResult_NonePaymentSendFailureZ_get_ok(long arg);
        public static native long LDKCResult_NonePaymentSendFailureZ_get_err(long arg);
-       public static native long LDKC2Tuple_PaymentHashPaymentIdZ_new(byte[] a, long b);
        // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_PaymentHashPaymentIdZ_get_a(long tuple);
-       // struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
-       public static native long C2Tuple_PaymentHashPaymentIdZ_get_b(long tuple);
+       // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
+       public static native byte[] C2Tuple_PaymentHashPaymentIdZ_get_b(long tuple);
        public static native boolean LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(long arg);
        public static native long LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(long arg);
        public static native long LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(long arg);
@@ -615,7 +638,6 @@ public class bindings {
        static { LDKNetAddress.init(); }
        public static native LDKNetAddress LDKNetAddress_ref_from_ptr(long ptr);
        public static native long LDKCVec_NetAddressZ_new(long[] elems);
-       public static native long LDKC2Tuple_PaymentHashPaymentSecretZ_new(byte[] a, byte[] b);
        // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_PaymentHashPaymentSecretZ_get_a(long tuple);
        // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple);
@@ -676,7 +698,6 @@ public class bindings {
                 void log(String record);
        }
        public static native long LDKLogger_new(LDKLogger impl);
-       public static native long LDKC2Tuple_BlockHashChannelManagerZ_new(byte[] a, long b);
        // struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_BlockHashChannelManagerZ_get_a(long tuple);
        // struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple);
@@ -718,6 +739,27 @@ public class bindings {
        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 class LDKPaymentError {
+               private LDKPaymentError() {}
+               public final static class Invoice extends LDKPaymentError {
+                       public String invoice;
+                       Invoice(String invoice) { this.invoice = invoice; }
+               }
+               public final static class Routing extends LDKPaymentError {
+                       public long routing;
+                       Routing(long routing) { this.routing = routing; }
+               }
+               public final static class Sending extends LDKPaymentError {
+                       public long sending;
+                       Sending(long sending) { this.sending = sending; }
+               }
+               static native void init();
+       }
+       static { LDKPaymentError.init(); }
+       public static native LDKPaymentError LDKPaymentError_ref_from_ptr(long ptr);
+       public static native boolean LDKCResult_PaymentIdPaymentErrorZ_result_ok(long arg);
+       public static native byte[] LDKCResult_PaymentIdPaymentErrorZ_get_ok(long arg);
+       public static native long LDKCResult_PaymentIdPaymentErrorZ_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);
@@ -727,7 +769,6 @@ public class bindings {
        public static native boolean LDKCResult_SignedRawInvoiceNoneZ_result_ok(long arg);
        public static native long LDKCResult_SignedRawInvoiceNoneZ_get_ok(long arg);
        public static native void LDKCResult_SignedRawInvoiceNoneZ_get_err(long arg);
-       public static native long LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(long a, byte[] b, long c);
        // struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple);
        public static native long C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(long tuple);
        // struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple);
@@ -768,18 +809,15 @@ public class bindings {
        public static native boolean LDKCResult_NoneMonitorUpdateErrorZ_result_ok(long arg);
        public static native void LDKCResult_NoneMonitorUpdateErrorZ_get_ok(long arg);
        public static native long LDKCResult_NoneMonitorUpdateErrorZ_get_err(long arg);
-       public static native long LDKC2Tuple_OutPointScriptZ_new(long a, byte[] b);
        // struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple);
        public static native long C2Tuple_OutPointScriptZ_get_a(long tuple);
        // struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_OutPointScriptZ_get_b(long tuple);
-       public static native long LDKC2Tuple_u32ScriptZ_new(int a, byte[] b);
        // uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple);
        public static native int C2Tuple_u32ScriptZ_get_a(long tuple);
        // struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_u32ScriptZ_get_b(long tuple);
        public static native long LDKCVec_C2Tuple_u32ScriptZZ_new(long[] elems);
-       public static native long LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(byte[] a, long[] b);
        // struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(long tuple);
        // struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple);
@@ -846,18 +884,22 @@ public class bindings {
                        PaymentReceived(byte[] payment_hash, long amt, long purpose) { this.payment_hash = payment_hash; this.amt = amt; this.purpose = purpose; }
                }
                public final static class PaymentSent extends LDKEvent {
+                       public byte[] payment_id;
                        public byte[] payment_preimage;
                        public byte[] payment_hash;
-                       PaymentSent(byte[] payment_preimage, byte[] payment_hash) { this.payment_preimage = payment_preimage; this.payment_hash = payment_hash; }
+                       public long fee_paid_msat;
+                       PaymentSent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, long fee_paid_msat) { this.payment_id = payment_id; this.payment_preimage = payment_preimage; this.payment_hash = payment_hash; this.fee_paid_msat = fee_paid_msat; }
                }
                public final static class PaymentPathFailed extends LDKEvent {
+                       public byte[] payment_id;
                        public byte[] payment_hash;
                        public boolean rejected_by_dest;
                        public long network_update;
                        public boolean all_paths_failed;
                        public long[] path;
                        public long short_channel_id;
-                       PaymentPathFailed(byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path, long short_channel_id) { 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; this.short_channel_id = short_channel_id; }
+                       public long retry;
+                       PaymentPathFailed(byte[] payment_id, byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path, long short_channel_id, long retry) { this.payment_id = payment_id; 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; this.short_channel_id = short_channel_id; this.retry = retry; }
                }
                public final static class PendingHTLCsForwardable extends LDKEvent {
                        public long time_forwardable;
@@ -888,13 +930,11 @@ public class bindings {
        static { LDKEvent.init(); }
        public static native LDKEvent LDKEvent_ref_from_ptr(long ptr);
        public static native long LDKCVec_EventZ_new(long[] elems);
-       public static native long LDKC2Tuple_u32TxOutZ_new(int a, long b);
        // uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple);
        public static native int C2Tuple_u32TxOutZ_get_a(long tuple);
        // struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple);
        public static native long C2Tuple_u32TxOutZ_get_b(long tuple);
        public static native long LDKCVec_C2Tuple_u32TxOutZZ_new(long[] elems);
-       public static native long LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(byte[] a, long[] b);
        // struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(long tuple);
        // struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple);
@@ -932,7 +972,6 @@ public class bindings {
        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);
        // struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple);
        public static native byte[] C2Tuple_PublicKeyTypeZ_get_a(long tuple);
        // struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple);
@@ -941,7 +980,6 @@ public class bindings {
        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);
-       public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(long a, long b, long c);
        // struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple);
        public static native long C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(long tuple);
        // struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple);
@@ -1013,12 +1051,6 @@ public class bindings {
        }
        static { LDKCOption_CVec_NetAddressZZ.init(); }
        public static native LDKCOption_CVec_NetAddressZZ LDKCOption_CVec_NetAddressZZ_ref_from_ptr(long ptr);
-       public static native boolean LDKCResult_NetAddressu8Z_result_ok(long arg);
-       public static native long LDKCResult_NetAddressu8Z_get_ok(long arg);
-       public static native byte LDKCResult_NetAddressu8Z_get_err(long arg);
-       public static native boolean LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(long arg);
-       public static native long LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(long arg);
-       public static native long LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(long arg);
        public static native boolean LDKCResult_NetAddressDecodeErrorZ_result_ok(long arg);
        public static native long LDKCResult_NetAddressDecodeErrorZ_get_ok(long arg);
        public static native long LDKCResult_NetAddressDecodeErrorZ_get_err(long arg);
@@ -1207,14 +1239,14 @@ public class bindings {
        // LDKCVec_TxidZ Confirm_get_relevant_txids LDKConfirm *NONNULL_PTR this_arg
        public static native byte[][] Confirm_get_relevant_txids(long this_arg);
        public interface LDKPersist {
-                long persist_new_channel(long id, long data);
-                long update_persisted_channel(long id, long update, long data);
+                long persist_new_channel(long channel_id, long data, long update_id);
+                long update_persisted_channel(long channel_id, long update, long data, long update_id);
        }
        public static native long LDKPersist_new(LDKPersist impl);
-       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_persist_new_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data
-       public static native long Persist_persist_new_channel(long this_arg, long id, long data);
-       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_update_persisted_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data
-       public static native long Persist_update_persisted_channel(long this_arg, long id, long update, long data);
+       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_persist_new_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id
+       public static native long Persist_persist_new_channel(long this_arg, long channel_id, long data, long update_id);
+       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_update_persisted_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id
+       public static native long Persist_update_persisted_channel(long this_arg, long channel_id, long update, long data, long update_id);
        public interface LDKChannelMessageHandler {
                 void handle_open_channel(byte[] their_node_id, long their_features, long msg);
                 void handle_accept_channel(byte[] their_node_id, long their_features, long msg);
@@ -1343,11 +1375,17 @@ public class bindings {
        // uint64_t SocketDescriptor_hash LDKSocketDescriptor *NONNULL_PTR this_arg
        public static native long SocketDescriptor_hash(long this_arg);
        public interface LDKScore {
-                long channel_penalty_msat(long short_channel_id);
+                long channel_penalty_msat(long short_channel_id, long source, long target);
+                void payment_path_failed(long[] path, long short_channel_id);
+                byte[] write();
        }
        public static native long LDKScore_new(LDKScore impl);
-       // uint64_t Score_channel_penalty_msat LDKScore *NONNULL_PTR this_arg, uint64_t short_channel_id
-       public static native long Score_channel_penalty_msat(long this_arg, long short_channel_id);
+       // uint64_t Score_channel_penalty_msat LDKScore *NONNULL_PTR this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target
+       public static native long Score_channel_penalty_msat(long this_arg, long short_channel_id, long source, long target);
+       // void Score_payment_path_failed LDKScore *NONNULL_PTR this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id
+       public static native void Score_payment_path_failed(long this_arg, long[] path, long short_channel_id);
+       // LDKCVec_u8Z Score_write LDKScore *NONNULL_PTR this_arg
+       public static native byte[] Score_write(long this_arg);
        public interface LDKChannelManagerPersister {
                 long persist_manager(long channel_manager);
        }
@@ -1373,6 +1411,27 @@ public class bindings {
        }
        static { LDKFallback.init(); }
        public static native LDKFallback LDKFallback_ref_from_ptr(long ptr);
+       public interface LDKPayer {
+                byte[] node_id();
+                long[] first_hops();
+                long send_payment(long route, byte[] payment_hash, byte[] payment_secret);
+                long retry_payment(long route, byte[] payment_id);
+       }
+       public static native long LDKPayer_new(LDKPayer impl);
+       // LDKPublicKey Payer_node_id LDKPayer *NONNULL_PTR this_arg
+       public static native byte[] Payer_node_id(long this_arg);
+       // LDKCVec_ChannelDetailsZ Payer_first_hops LDKPayer *NONNULL_PTR this_arg
+       public static native long[] Payer_first_hops(long this_arg);
+       // LDKCResult_PaymentIdPaymentSendFailureZ Payer_send_payment LDKPayer *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret
+       public static native long Payer_send_payment(long this_arg, long route, byte[] payment_hash, byte[] payment_secret);
+       // LDKCResult_NonePaymentSendFailureZ Payer_retry_payment LDKPayer *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id
+       public static native long Payer_retry_payment(long this_arg, long route, byte[] payment_id);
+       public interface LDKRouter {
+                long find_route(byte[] payer, long params, long[] first_hops, long scorer);
+       }
+       public static native long LDKRouter_new(LDKRouter impl);
+       // LDKCResult_RouteLightningErrorZ Router_find_route LDKRouter *NONNULL_PTR this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer
+       public static native long Router_find_route(long this_arg, byte[] payer, long params, long[] first_hops, long scorer);
        // struct LDKStr _ldk_get_compiled_version(void);
        public static native String _ldk_get_compiled_version();
        // struct LDKStr _ldk_c_bindings_get_compiled_version(void);
@@ -1517,6 +1576,8 @@ public class bindings {
        public static native long CResult_ShutdownScriptInvalidShutdownScriptZ_err(long e);
        // void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res);
        public static native void CResult_ShutdownScriptInvalidShutdownScriptZ_free(long _res);
+       // struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig);
+       public static native long CResult_ShutdownScriptInvalidShutdownScriptZ_clone(long orig);
        // struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void);
        public static native long CResult_NoneErrorZ_ok();
        // struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e);
@@ -1545,6 +1606,16 @@ public class bindings {
        public static native void CResult_RouteDecodeErrorZ_free(long _res);
        // struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig);
        public static native long CResult_RouteDecodeErrorZ_clone(long orig);
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o);
+       public static native long CResult_RouteParametersDecodeErrorZ_ok(long o);
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_RouteParametersDecodeErrorZ_err(long e);
+       // void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res);
+       public static native void CResult_RouteParametersDecodeErrorZ_free(long _res);
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig);
+       public static native long CResult_RouteParametersDecodeErrorZ_clone(long orig);
+       // void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res);
+       public static native void CVec_RouteHintZ_free(long[] _res);
        // struct LDKCOption_u64Z COption_u64Z_some(uint64_t o);
        public static native long COption_u64Z_some(long o);
        // struct LDKCOption_u64Z COption_u64Z_none(void);
@@ -1553,10 +1624,34 @@ public class bindings {
        public static native void COption_u64Z_free(long _res);
        // struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig);
        public static native long COption_u64Z_clone(long orig);
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_ok(struct LDKPayee o);
+       public static native long CResult_PayeeDecodeErrorZ_ok(long o);
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_PayeeDecodeErrorZ_err(long e);
+       // void CResult_PayeeDecodeErrorZ_free(struct LDKCResult_PayeeDecodeErrorZ _res);
+       public static native void CResult_PayeeDecodeErrorZ_free(long _res);
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_clone(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR orig);
+       public static native long CResult_PayeeDecodeErrorZ_clone(long orig);
+       // void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res);
+       public static native void CVec_RouteHintHopZ_free(long[] _res);
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o);
+       public static native long CResult_RouteHintDecodeErrorZ_ok(long o);
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_RouteHintDecodeErrorZ_err(long e);
+       // void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res);
+       public static native void CResult_RouteHintDecodeErrorZ_free(long _res);
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig);
+       public static native long CResult_RouteHintDecodeErrorZ_clone(long orig);
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o);
+       public static native long CResult_RouteHintHopDecodeErrorZ_ok(long o);
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_RouteHintHopDecodeErrorZ_err(long e);
+       // void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res);
+       public static native void CResult_RouteHintHopDecodeErrorZ_free(long _res);
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig);
+       public static native long CResult_RouteHintHopDecodeErrorZ_clone(long orig);
        // void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res);
        public static native void CVec_ChannelDetailsZ_free(long[] _res);
-       // void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res);
-       public static native void CVec_RouteHintZ_free(long[] _res);
        // struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o);
        public static native long CResult_RouteLightningErrorZ_ok(long o);
        // struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e);
@@ -1637,6 +1732,18 @@ public class bindings {
        public static native long CResult_InvoiceFeaturesDecodeErrorZ_err(long e);
        // void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res);
        public static native void CResult_InvoiceFeaturesDecodeErrorZ_free(long _res);
+       // struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o);
+       public static native long CResult_ScoringParametersDecodeErrorZ_ok(long o);
+       // struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_ScoringParametersDecodeErrorZ_err(long e);
+       // void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res);
+       public static native void CResult_ScoringParametersDecodeErrorZ_free(long _res);
+       // struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o);
+       public static native long CResult_ScorerDecodeErrorZ_ok(long o);
+       // struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e);
+       public static native long CResult_ScorerDecodeErrorZ_err(long e);
+       // void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res);
+       public static native void CResult_ScorerDecodeErrorZ_free(long _res);
        // struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o);
        public static native long CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(long o);
        // struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e);
@@ -1753,14 +1860,6 @@ public class bindings {
        public static native void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(long _res);
        // struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR orig);
        public static native long CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(long orig);
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_ok(struct LDKPaymentId o);
-       public static native long CResult_PaymentIdDecodeErrorZ_ok(long o);
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_err(struct LDKDecodeError e);
-       public static native long CResult_PaymentIdDecodeErrorZ_err(long e);
-       // void CResult_PaymentIdDecodeErrorZ_free(struct LDKCResult_PaymentIdDecodeErrorZ _res);
-       public static native void CResult_PaymentIdDecodeErrorZ_free(long _res);
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_clone(const struct LDKCResult_PaymentIdDecodeErrorZ *NONNULL_PTR orig);
-       public static native long CResult_PaymentIdDecodeErrorZ_clone(long orig);
        // struct LDKCOption_u16Z COption_u16Z_some(uint16_t o);
        public static native long COption_u16Z_some(short o);
        // struct LDKCOption_u16Z COption_u16Z_none(void);
@@ -1789,8 +1888,8 @@ public class bindings {
        public static native void CResult__u832APIErrorZ_free(long _res);
        // struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_clone(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR orig);
        public static native long CResult__u832APIErrorZ_clone(long orig);
-       // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKPaymentId o);
-       public static native long CResult_PaymentIdPaymentSendFailureZ_ok(long o);
+       // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o);
+       public static native long CResult_PaymentIdPaymentSendFailureZ_ok(byte[] o);
        // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
        public static native long CResult_PaymentIdPaymentSendFailureZ_err(long e);
        // void CResult_PaymentIdPaymentSendFailureZ_free(struct LDKCResult_PaymentIdPaymentSendFailureZ _res);
@@ -1807,8 +1906,8 @@ public class bindings {
        public static native long CResult_NonePaymentSendFailureZ_clone(long orig);
        // struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_clone(const struct LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR orig);
        public static native long C2Tuple_PaymentHashPaymentIdZ_clone(long orig);
-       // struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKPaymentId b);
-       public static native long C2Tuple_PaymentHashPaymentIdZ_new(byte[] a, long b);
+       // struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b);
+       public static native long C2Tuple_PaymentHashPaymentIdZ_new(byte[] a, byte[] b);
        // void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res);
        public static native void C2Tuple_PaymentHashPaymentIdZ_free(long _res);
        // struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(struct LDKC2Tuple_PaymentHashPaymentIdZ o);
@@ -1879,6 +1978,14 @@ public class bindings {
        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_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o);
+       public static native long CResult_PaymentIdPaymentErrorZ_ok(byte[] o);
+       // struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e);
+       public static native long CResult_PaymentIdPaymentErrorZ_err(long e);
+       // void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res);
+       public static native void CResult_PaymentIdPaymentErrorZ_free(long _res);
+       // struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig);
+       public static native long CResult_PaymentIdPaymentErrorZ_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);
@@ -2181,22 +2288,6 @@ public class bindings {
        public static native void COption_CVec_NetAddressZZ_free(long _res);
        // struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_clone(const struct LDKCOption_CVec_NetAddressZZ *NONNULL_PTR orig);
        public static native long COption_CVec_NetAddressZZ_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);
-       public static native long CResult_NetAddressu8Z_err(byte e);
-       // void CResult_NetAddressu8Z_free(struct LDKCResult_NetAddressu8Z _res);
-       public static native void CResult_NetAddressu8Z_free(long _res);
-       // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const struct LDKCResult_NetAddressu8Z *NONNULL_PTR orig);
-       public static native long CResult_NetAddressu8Z_clone(long orig);
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(struct LDKCResult_NetAddressu8Z o);
-       public static native long CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(long o);
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_err(struct LDKDecodeError e);
-       public static native long CResult_CResult_NetAddressu8ZDecodeErrorZ_err(long e);
-       // void CResult_CResult_NetAddressu8ZDecodeErrorZ_free(struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res);
-       public static native void CResult_CResult_NetAddressu8ZDecodeErrorZ_free(long _res);
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(const struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *NONNULL_PTR orig);
-       public static native long CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(long orig);
        // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o);
        public static native long CResult_NetAddressDecodeErrorZ_ok(long o);
        // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e);
@@ -2527,10 +2618,10 @@ public class bindings {
        public static native long Event_funding_generation_ready(byte[] temporary_channel_id, long channel_value_satoshis, byte[] output_script, long user_channel_id);
        // struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, uint64_t amt, struct LDKPaymentPurpose purpose);
        public static native long Event_payment_received(byte[] payment_hash, long amt, long purpose);
-       // struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash);
-       public static native long Event_payment_sent(byte[] payment_preimage, byte[] payment_hash);
-       // 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, struct LDKCOption_u64Z short_channel_id);
-       public static native long Event_payment_path_failed(byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path, long short_channel_id);
+       // struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat);
+       public static native long Event_payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, long fee_paid_msat);
+       // struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry);
+       public static native long Event_payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean rejected_by_dest, long network_update, boolean all_paths_failed, long[] path, long short_channel_id, long retry);
        // 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);
@@ -2825,6 +2916,14 @@ public class bindings {
        public static native boolean ConfirmationTarget_eq(long a, long b);
        // void FeeEstimator_free(struct LDKFeeEstimator this_ptr);
        public static native void FeeEstimator_free(long this_ptr);
+       // void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj);
+       public static native void MonitorUpdateId_free(long this_obj);
+       // struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig);
+       public static native long MonitorUpdateId_clone(long orig);
+       // uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o);
+       public static native long MonitorUpdateId_hash(long o);
+       // bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b);
+       public static native boolean MonitorUpdateId_eq(long a, long b);
        // void Persist_free(struct LDKPersist this_ptr);
        public static native void Persist_free(long this_ptr);
        // void LockedChannelMonitor_free(struct LDKLockedChannelMonitor this_obj);
@@ -2839,6 +2938,8 @@ public class bindings {
        public static native long ChainMonitor_get_monitor(long this_arg, long funding_txo);
        // MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg);
        public static native long[] ChainMonitor_list_monitors(long this_arg);
+       // MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, struct LDKMonitorUpdateId completed_update_id);
+       public static native long ChainMonitor_channel_monitor_updated(long this_arg, long funding_txo, long completed_update_id);
        // 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);
@@ -2861,6 +2962,12 @@ public class bindings {
        public static native long ChannelMonitorUpdate_read(byte[] ser);
        // void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj);
        public static native void MonitorUpdateError_free(long this_obj);
+       // struct LDKStr MonitorUpdateError_get_a(const struct LDKMonitorUpdateError *NONNULL_PTR this_ptr);
+       public static native String MonitorUpdateError_get_a(long this_ptr);
+       // void MonitorUpdateError_set_a(struct LDKMonitorUpdateError *NONNULL_PTR this_ptr, struct LDKStr val);
+       public static native void MonitorUpdateError_set_a(long this_ptr, String val);
+       // MUST_USE_RES struct LDKMonitorUpdateError MonitorUpdateError_new(struct LDKStr a_arg);
+       public static native long MonitorUpdateError_new(String a_arg);
        // struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig);
        public static native long MonitorUpdateError_clone(long orig);
        // void MonitorEvent_free(struct LDKMonitorEvent this_ptr);
@@ -2871,6 +2978,12 @@ public class bindings {
        public static native long MonitorEvent_htlcevent(long a);
        // struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a);
        public static native long MonitorEvent_commitment_tx_confirmed(long a);
+       // struct LDKMonitorEvent MonitorEvent_update_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id);
+       public static native long MonitorEvent_update_completed(long funding_txo, long monitor_update_id);
+       // struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a);
+       public static native long MonitorEvent_update_failed(long a);
+       // struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj);
+       public static native byte[] MonitorEvent_write(long obj);
        // 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);
@@ -3103,18 +3216,6 @@ public class bindings {
        public static native long KeysManager_spend_spendable_outputs(long this_arg, long[] descriptors, long[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight);
        // struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg);
        public static native long KeysManager_as_KeysInterface(long this_arg);
-       // void PaymentId_free(struct LDKPaymentId this_obj);
-       public static native void PaymentId_free(long this_obj);
-       // uint64_t PaymentId_hash(const struct LDKPaymentId *NONNULL_PTR o);
-       public static native long PaymentId_hash(long o);
-       // struct LDKPaymentId PaymentId_clone(const struct LDKPaymentId *NONNULL_PTR orig);
-       public static native long PaymentId_clone(long orig);
-       // bool PaymentId_eq(const struct LDKPaymentId *NONNULL_PTR a, const struct LDKPaymentId *NONNULL_PTR b);
-       public static native boolean PaymentId_eq(long a, long b);
-       // struct LDKCVec_u8Z PaymentId_write(const struct LDKPaymentId *NONNULL_PTR obj);
-       public static native byte[] PaymentId_write(long obj);
-       // struct LDKCResult_PaymentIdDecodeErrorZ PaymentId_read(struct LDKu8slice ser);
-       public static native long PaymentId_read(byte[] ser);
        // void ChannelManager_free(struct LDKChannelManager this_obj);
        public static native void ChannelManager_free(long this_obj);
        // void ChainParameters_free(struct LDKChainParameters this_obj);
@@ -3247,8 +3348,8 @@ public class bindings {
        public static native long PaymentSendFailure_path_parameter_error(long[] a);
        // struct LDKPaymentSendFailure PaymentSendFailure_all_failed_retry_safe(struct LDKCVec_APIErrorZ a);
        public static native long PaymentSendFailure_all_failed_retry_safe(long[] a);
-       // struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ a);
-       public static native long PaymentSendFailure_partial_failure(long[] a);
+       // struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id);
+       public static native long PaymentSendFailure_partial_failure(long[] results, long failed_paths_retry, byte[] payment_id);
        // MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params);
        public static native long ChannelManager_new(long fee_est, long chain_monitor, long tx_broadcaster, long logger, long keys_manager, long config, long params);
        // MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg);
@@ -3269,8 +3370,8 @@ public class bindings {
        public static native void ChannelManager_force_close_all_channels(long this_arg);
        // MUST_USE_RES struct LDKCResult_PaymentIdPaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret);
        public static native long ChannelManager_send_payment(long this_arg, long route, byte[] payment_hash, byte[] payment_secret);
-       // MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKPaymentId payment_id);
-       public static native long ChannelManager_retry_payment(long this_arg, long route, long payment_id);
+       // MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id);
+       public static native long ChannelManager_retry_payment(long this_arg, long route, byte[] payment_id);
        // MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage);
        public static native long ChannelManager_send_spontaneous_payment(long this_arg, long route, byte[] payment_preimage);
        // MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKTransaction funding_transaction);
@@ -3287,8 +3388,6 @@ public class bindings {
        public static native boolean ChannelManager_claim_funds(long this_arg, byte[] payment_preimage);
        // MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg);
        public static native byte[] ChannelManager_get_our_node_id(long this_arg);
-       // void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOutPoint *NONNULL_PTR funding_txo, uint64_t highest_applied_update_id);
-       public static native void ChannelManager_channel_monitor_updated(long this_arg, long funding_txo, long highest_applied_update_id);
        // MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id);
        public static native long ChannelManager_create_inbound_payment(long this_arg, long min_value_msat, int invoice_expiry_delta_secs, long user_payment_id);
        // MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id);
@@ -3813,8 +3912,6 @@ public class bindings {
        public static native long NetAddress_onion_v3(byte[] ed25519_pubkey, short checksum, byte version, short port);
        // struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj);
        public static native byte[] NetAddress_write(long obj);
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser);
-       public static native long Result_read(byte[] ser);
        // struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser);
        public static native long NetAddress_read(byte[] ser);
        // void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj);
@@ -4309,6 +4406,8 @@ public class bindings {
        public static native void PeerManager_socket_disconnected(long this_arg, long descriptor);
        // void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible);
        public static native void PeerManager_disconnect_by_node_id(long this_arg, byte[] node_id, boolean no_connection_possible);
+       // void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg);
+       public static native void PeerManager_disconnect_all_peers(long this_arg);
        // void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
        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);
@@ -4531,6 +4630,10 @@ public class bindings {
        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);
+       // struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig);
+       public static native long ClosingTransaction_clone(long orig);
+       // uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o);
+       public static native long ClosingTransaction_hash(long o);
        // 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);
@@ -4667,6 +4770,8 @@ public class bindings {
        public static native void InvalidShutdownScript_set_script(long this_ptr, byte[] val);
        // MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg);
        public static native long InvalidShutdownScript_new(byte[] script_arg);
+       // struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig);
+       public static native long InvalidShutdownScript_clone(long orig);
        // struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj);
        public static native byte[] ShutdownScript_write(long obj);
        // struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser);
@@ -4691,6 +4796,12 @@ public class bindings {
        public static native void Type_free(long this_ptr);
        // void Score_free(struct LDKScore this_ptr);
        public static native void Score_free(long this_ptr);
+       // void LockableScore_free(struct LDKLockableScore this_obj);
+       public static native void LockableScore_free(long this_obj);
+       // MUST_USE_RES struct LDKLockableScore LockableScore_new(struct LDKScore score);
+       public static native long LockableScore_new(long score);
+       // struct LDKCVec_u8Z LockableScore_write(const struct LDKLockableScore *NONNULL_PTR obj);
+       public static native byte[] LockableScore_write(long obj);
        // void NodeId_free(struct LDKNodeId this_obj);
        public static native void NodeId_free(long this_obj);
        // struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig);
@@ -4727,11 +4838,7 @@ public class bindings {
        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);
-       // 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);
+       // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(const struct LDKNetworkGraph *NONNULL_PTR 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);
@@ -4959,8 +5066,12 @@ public class bindings {
        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 LDKPayee Route_get_payee(const struct LDKRoute *NONNULL_PTR this_ptr);
+       public static native long Route_get_payee(long this_ptr);
+       // void Route_set_payee(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPayee val);
+       public static native void Route_set_payee(long this_ptr, long val);
+       // MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKPayee payee_arg);
+       public static native long Route_new(long[][] paths_arg, long payee_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);
@@ -4975,14 +5086,80 @@ public class bindings {
        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 RouteParameters_free(struct LDKRouteParameters this_obj);
+       public static native void RouteParameters_free(long this_obj);
+       // struct LDKPayee RouteParameters_get_payee(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       public static native long RouteParameters_get_payee(long this_ptr);
+       // void RouteParameters_set_payee(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPayee val);
+       public static native void RouteParameters_set_payee(long this_ptr, long val);
+       // uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       public static native long RouteParameters_get_final_value_msat(long this_ptr);
+       // void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val);
+       public static native void RouteParameters_set_final_value_msat(long this_ptr, long val);
+       // uint32_t RouteParameters_get_final_cltv_expiry_delta(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       public static native int RouteParameters_get_final_cltv_expiry_delta(long this_ptr);
+       // void RouteParameters_set_final_cltv_expiry_delta(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint32_t val);
+       public static native void RouteParameters_set_final_cltv_expiry_delta(long this_ptr, int val);
+       // MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPayee payee_arg, uint64_t final_value_msat_arg, uint32_t final_cltv_expiry_delta_arg);
+       public static native long RouteParameters_new(long payee_arg, long final_value_msat_arg, int final_cltv_expiry_delta_arg);
+       // struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig);
+       public static native long RouteParameters_clone(long orig);
+       // struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj);
+       public static native byte[] RouteParameters_write(long obj);
+       // struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser);
+       public static native long RouteParameters_read(byte[] ser);
+       // void Payee_free(struct LDKPayee this_obj);
+       public static native void Payee_free(long this_obj);
+       // struct LDKPublicKey Payee_get_pubkey(const struct LDKPayee *NONNULL_PTR this_ptr);
+       public static native byte[] Payee_get_pubkey(long this_ptr);
+       // void Payee_set_pubkey(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+       public static native void Payee_set_pubkey(long this_ptr, byte[] val);
+       // struct LDKInvoiceFeatures Payee_get_features(const struct LDKPayee *NONNULL_PTR this_ptr);
+       public static native long Payee_get_features(long this_ptr);
+       // void Payee_set_features(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKInvoiceFeatures val);
+       public static native void Payee_set_features(long this_ptr, long val);
+       // struct LDKCVec_RouteHintZ Payee_get_route_hints(const struct LDKPayee *NONNULL_PTR this_ptr);
+       public static native long[] Payee_get_route_hints(long this_ptr);
+       // void Payee_set_route_hints(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintZ val);
+       public static native void Payee_set_route_hints(long this_ptr, long[] val);
+       // struct LDKCOption_u64Z Payee_get_expiry_time(const struct LDKPayee *NONNULL_PTR this_ptr);
+       public static native long Payee_get_expiry_time(long this_ptr);
+       // void Payee_set_expiry_time(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
+       public static native void Payee_set_expiry_time(long this_ptr, long val);
+       // MUST_USE_RES struct LDKPayee Payee_new(struct LDKPublicKey pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg);
+       public static native long Payee_new(byte[] pubkey_arg, long features_arg, long[] route_hints_arg, long expiry_time_arg);
+       // struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig);
+       public static native long Payee_clone(long orig);
+       // uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o);
+       public static native long Payee_hash(long o);
+       // bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b);
+       public static native boolean Payee_eq(long a, long b);
+       // struct LDKCVec_u8Z Payee_write(const struct LDKPayee *NONNULL_PTR obj);
+       public static native byte[] Payee_write(long obj);
+       // struct LDKCResult_PayeeDecodeErrorZ Payee_read(struct LDKu8slice ser);
+       public static native long Payee_read(byte[] ser);
+       // MUST_USE_RES struct LDKPayee Payee_from_node_id(struct LDKPublicKey pubkey);
+       public static native long Payee_from_node_id(byte[] pubkey);
+       // MUST_USE_RES struct LDKPayee Payee_for_keysend(struct LDKPublicKey pubkey);
+       public static native long Payee_for_keysend(byte[] pubkey);
        // void RouteHint_free(struct LDKRouteHint this_obj);
        public static native void RouteHint_free(long this_obj);
+       // struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr);
+       public static native long[] RouteHint_get_a(long this_ptr);
+       // void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val);
+       public static native void RouteHint_set_a(long this_ptr, long[] val);
+       // MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg);
+       public static native long RouteHint_new(long[] a_arg);
        // 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);
+       // struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj);
+       public static native byte[] RouteHint_write(long obj);
+       // struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser);
+       public static native long RouteHint_read(byte[] ser);
        // 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);
@@ -5017,18 +5194,46 @@ public class bindings {
        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_pubkey, 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, const struct LDKScore *NONNULL_PTR scorer);
-       public static native long get_keysend_route(byte[] our_node_pubkey, long network, byte[] payee, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger, long scorer);
-       // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_pubkey, 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, const struct LDKScore *NONNULL_PTR scorer);
-       public static native long get_route(byte[] our_node_pubkey, long network, byte[] payee, long payee_features, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger, long scorer);
+       // struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj);
+       public static native byte[] RouteHintHop_write(long obj);
+       // struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser);
+       public static native long RouteHintHop_read(byte[] ser);
+       // struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer);
+       public static native long find_route(byte[] our_node_pubkey, long params, long network, long[] first_hops, long logger, long scorer);
        // void Scorer_free(struct LDKScorer this_obj);
        public static native void Scorer_free(long this_obj);
-       // MUST_USE_RES struct LDKScorer Scorer_new(uint64_t base_penalty_msat);
-       public static native long Scorer_new(long base_penalty_msat);
+       // void ScoringParameters_free(struct LDKScoringParameters this_obj);
+       public static native void ScoringParameters_free(long this_obj);
+       // uint64_t ScoringParameters_get_base_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       public static native long ScoringParameters_get_base_penalty_msat(long this_ptr);
+       // void ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       public static native void ScoringParameters_set_base_penalty_msat(long this_ptr, long val);
+       // uint64_t ScoringParameters_get_failure_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       public static native long ScoringParameters_get_failure_penalty_msat(long this_ptr);
+       // void ScoringParameters_set_failure_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       public static native void ScoringParameters_set_failure_penalty_msat(long this_ptr, long val);
+       // uint64_t ScoringParameters_get_failure_penalty_half_life(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       public static native long ScoringParameters_get_failure_penalty_half_life(long this_ptr);
+       // void ScoringParameters_set_failure_penalty_half_life(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       public static native void ScoringParameters_set_failure_penalty_half_life(long this_ptr, long val);
+       // MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint64_t failure_penalty_half_life_arg);
+       public static native long ScoringParameters_new(long base_penalty_msat_arg, long failure_penalty_msat_arg, long failure_penalty_half_life_arg);
+       // struct LDKCVec_u8Z ScoringParameters_write(const struct LDKScoringParameters *NONNULL_PTR obj);
+       public static native byte[] ScoringParameters_write(long obj);
+       // struct LDKCResult_ScoringParametersDecodeErrorZ ScoringParameters_read(struct LDKu8slice ser);
+       public static native long ScoringParameters_read(byte[] ser);
+       // MUST_USE_RES struct LDKScorer Scorer_new(struct LDKScoringParameters params);
+       public static native long Scorer_new(long params);
        // MUST_USE_RES struct LDKScorer Scorer_default(void);
        public static native long Scorer_default();
+       // MUST_USE_RES struct LDKScoringParameters ScoringParameters_default(void);
+       public static native long ScoringParameters_default();
        // struct LDKScore Scorer_as_Score(const struct LDKScorer *NONNULL_PTR this_arg);
        public static native long Scorer_as_Score(long this_arg);
+       // struct LDKCVec_u8Z Scorer_write(const struct LDKScorer *NONNULL_PTR obj);
+       public static native byte[] Scorer_write(long obj);
+       // struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser);
+       public static native long Scorer_read(byte[] ser);
        // void FilesystemPersister_free(struct LDKFilesystemPersister this_obj);
        public static native void FilesystemPersister_free(long this_obj);
        // MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKStr path_to_channel_data);
@@ -5139,6 +5344,12 @@ public class bindings {
        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);
+       // struct LDKPublicKey PayeePubKey_get_a(const struct LDKPayeePubKey *NONNULL_PTR this_ptr);
+       public static native byte[] PayeePubKey_get_a(long this_ptr);
+       // void PayeePubKey_set_a(struct LDKPayeePubKey *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+       public static native void PayeePubKey_set_a(long this_ptr, byte[] val);
+       // MUST_USE_RES struct LDKPayeePubKey PayeePubKey_new(struct LDKPublicKey a_arg);
+       public static native long PayeePubKey_new(byte[] a_arg);
        // 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);
@@ -5155,6 +5366,12 @@ public class bindings {
        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);
+       // uint64_t MinFinalCltvExpiry_get_a(const struct LDKMinFinalCltvExpiry *NONNULL_PTR this_ptr);
+       public static native long MinFinalCltvExpiry_get_a(long this_ptr);
+       // void MinFinalCltvExpiry_set_a(struct LDKMinFinalCltvExpiry *NONNULL_PTR this_ptr, uint64_t val);
+       public static native void MinFinalCltvExpiry_set_a(long this_ptr, long val);
+       // MUST_USE_RES struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_new(uint64_t a_arg);
+       public static native long MinFinalCltvExpiry_new(long a_arg);
        // 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);
@@ -5245,7 +5462,7 @@ public class bindings {
        public static native byte[] Invoice_payment_hash(long this_arg);
        // MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg);
        public static native byte[] Invoice_payee_pub_key(long this_arg);
-       // MUST_USE_RES struct LDKThirtyTwoBytes Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg);
+       // MUST_USE_RES const uint8_t (*Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg))[32];
        public static native byte[] Invoice_payment_secret(long this_arg);
        // MUST_USE_RES struct LDKInvoiceFeatures Invoice_features(const struct LDKInvoice *NONNULL_PTR this_arg);
        public static native long Invoice_features(long this_arg);
@@ -5253,6 +5470,8 @@ public class bindings {
        public static native byte[] Invoice_recover_payee_pub_key(long this_arg);
        // MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR this_arg);
        public static native long Invoice_expiry_time(long this_arg);
+       // MUST_USE_RES bool Invoice_is_expired(const struct LDKInvoice *NONNULL_PTR this_arg);
+       public static native boolean Invoice_is_expired(long this_arg);
        // MUST_USE_RES uint64_t Invoice_min_final_cltv_expiry(const struct LDKInvoice *NONNULL_PTR this_arg);
        public static native long Invoice_min_final_cltv_expiry(long this_arg);
        // MUST_USE_RES struct LDKCVec_PrivateRouteZ Invoice_private_routes(const struct LDKInvoice *NONNULL_PTR this_arg);
@@ -5261,8 +5480,8 @@ public class bindings {
        public static native long[] Invoice_route_hints(long this_arg);
        // MUST_USE_RES enum LDKCurrency Invoice_currency(const struct LDKInvoice *NONNULL_PTR this_arg);
        public static native Currency Invoice_currency(long this_arg);
-       // MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_pico_btc(const struct LDKInvoice *NONNULL_PTR this_arg);
-       public static native long Invoice_amount_pico_btc(long this_arg);
+       // MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_milli_satoshis(const struct LDKInvoice *NONNULL_PTR this_arg);
+       public static native long Invoice_amount_milli_satoshis(long this_arg);
        // MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKStr description);
        public static native long Description_new(String description);
        // MUST_USE_RES struct LDKStr Description_into_inner(struct LDKDescription this_arg);
@@ -5331,8 +5550,56 @@ public class bindings {
        public static native boolean SignOrCreationError_eq(long a, long b);
        // struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o);
        public static native String SignOrCreationError_to_str(long o);
+       // void InvoicePayer_free(struct LDKInvoicePayer this_obj);
+       public static native void InvoicePayer_free(long this_obj);
+       // void Payer_free(struct LDKPayer this_ptr);
+       public static native void Payer_free(long this_ptr);
+       // void Router_free(struct LDKRouter this_ptr);
+       public static native void Router_free(long this_ptr);
+       // void RetryAttempts_free(struct LDKRetryAttempts this_obj);
+       public static native void RetryAttempts_free(long this_obj);
+       // uintptr_t RetryAttempts_get_a(const struct LDKRetryAttempts *NONNULL_PTR this_ptr);
+       public static native long RetryAttempts_get_a(long this_ptr);
+       // void RetryAttempts_set_a(struct LDKRetryAttempts *NONNULL_PTR this_ptr, uintptr_t val);
+       public static native void RetryAttempts_set_a(long this_ptr, long val);
+       // MUST_USE_RES struct LDKRetryAttempts RetryAttempts_new(uintptr_t a_arg);
+       public static native long RetryAttempts_new(long a_arg);
+       // struct LDKRetryAttempts RetryAttempts_clone(const struct LDKRetryAttempts *NONNULL_PTR orig);
+       public static native long RetryAttempts_clone(long orig);
+       // bool RetryAttempts_eq(const struct LDKRetryAttempts *NONNULL_PTR a, const struct LDKRetryAttempts *NONNULL_PTR b);
+       public static native boolean RetryAttempts_eq(long a, long b);
+       // uint64_t RetryAttempts_hash(const struct LDKRetryAttempts *NONNULL_PTR o);
+       public static native long RetryAttempts_hash(long o);
+       // void PaymentError_free(struct LDKPaymentError this_ptr);
+       public static native void PaymentError_free(long this_ptr);
+       // struct LDKPaymentError PaymentError_clone(const struct LDKPaymentError *NONNULL_PTR orig);
+       public static native long PaymentError_clone(long orig);
+       // struct LDKPaymentError PaymentError_invoice(struct LDKStr a);
+       public static native long PaymentError_invoice(String a);
+       // struct LDKPaymentError PaymentError_routing(struct LDKLightningError a);
+       public static native long PaymentError_routing(long a);
+       // struct LDKPaymentError PaymentError_sending(struct LDKPaymentSendFailure a);
+       public static native long PaymentError_sending(long a);
+       // MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts);
+       public static native long InvoicePayer_new(long payer, long router, long scorer, long logger, long event_handler, long retry_attempts);
+       // MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice);
+       public static native long InvoicePayer_pay_invoice(long this_arg, long invoice);
+       // MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_zero_value_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats);
+       public static native long InvoicePayer_pay_zero_value_invoice(long this_arg, long invoice, long amount_msats);
+       // void InvoicePayer_remove_cached_payment(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]);
+       public static native void InvoicePayer_remove_cached_payment(long this_arg, byte[] payment_hash);
+       // struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer *NONNULL_PTR this_arg);
+       public static native long InvoicePayer_as_EventHandler(long this_arg);
        // struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description);
        public static native long create_invoice_from_channelmanager(long channelmanager, long keys_manager, Currency network, long amt_msat, String description);
+       // void DefaultRouter_free(struct LDKDefaultRouter this_obj);
+       public static native void DefaultRouter_free(long this_obj);
+       // MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger);
+       public static native long DefaultRouter_new(long network_graph, long logger);
+       // struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg);
+       public static native long DefaultRouter_as_Router(long this_arg);
+       // struct LDKPayer ChannelManager_as_Payer(const struct LDKChannelManager *NONNULL_PTR this_arg);
+       public static native long ChannelManager_as_Payer(long this_arg);
        // struct LDKCResult_SiPrefixNoneZ SiPrefix_from_str(struct LDKStr s);
        public static native long SiPrefix_from_str(String s);
        // struct LDKCResult_InvoiceNoneZ Invoice_from_str(struct LDKStr s);
index d82d0a5aea1ba3d623ee4e745ad6a4324dbd3707..e2613fd9e6a343a7655a5e40dcb0414d095f1d35 100644 (file)
@@ -100,7 +100,7 @@ public class APIError extends CommonBase {
                private IncompatibleShutdownScript(long ptr, bindings.LDKAPIError.IncompatibleShutdownScript obj) {
                        super(null, ptr);
                        long script = obj.script;
-                       ShutdownScript script_hu_conv = new ShutdownScript(null, script);
+                       ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new ShutdownScript(null, script); }
                        script_hu_conv.ptrs_to.add(this);
                        this.script = script_hu_conv;
                }
@@ -110,7 +110,7 @@ public class APIError extends CommonBase {
         */
        public APIError clone() {
                long ret = bindings.APIError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -121,7 +121,7 @@ public class APIError extends CommonBase {
         */
        public static APIError apimisuse_error(java.lang.String err) {
                long ret = bindings.APIError_apimisuse_error(err);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -132,7 +132,7 @@ public class APIError extends CommonBase {
         */
        public static APIError fee_rate_too_high(java.lang.String err, int feerate) {
                long ret = bindings.APIError_fee_rate_too_high(err, feerate);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -143,7 +143,7 @@ public class APIError extends CommonBase {
         */
        public static APIError route_error(java.lang.String err) {
                long ret = bindings.APIError_route_error(err);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -154,7 +154,7 @@ public class APIError extends CommonBase {
         */
        public static APIError channel_unavailable(java.lang.String err) {
                long ret = bindings.APIError_channel_unavailable(err);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -165,7 +165,7 @@ public class APIError extends CommonBase {
         */
        public static APIError monitor_update_failed() {
                long ret = bindings.APIError_monitor_update_failed();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -176,7 +176,7 @@ public class APIError extends CommonBase {
         */
        public static APIError incompatible_shutdown_script(ShutdownScript script) {
                long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                APIError ret_hu_conv = APIError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 78a390bc9f688958ac304b5f667de1089f90b6b1..09125fe31b528e7520fcaf7b0d758a1576b6f000 100644 (file)
@@ -234,8 +234,8 @@ public class AcceptChannel extends CommonBase {
         */
        public AcceptChannel clone() {
                long ret = bindings.AcceptChannel_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               AcceptChannel ret_hu_conv = new AcceptChannel(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new AcceptChannel(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -253,7 +253,7 @@ public class AcceptChannel extends CommonBase {
         */
        public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
                long ret = bindings.AcceptChannel_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 6a52297e936c17581eac4b3c075d1146f13480f6..47f0c93667197bef58cd6ebd3fea387743901869 100644 (file)
@@ -55,7 +55,7 @@ public class Access extends CommonBase {
         */
        public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
                long ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index bdc666679b13250075eadebe23626389ccda8b42..61e6ce021a182062d22cc870cf2633a266bb88fd 100644 (file)
@@ -84,8 +84,8 @@ public class AnnouncementSignatures extends CommonBase {
         */
        public static AnnouncementSignatures of(byte[] channel_id_arg, long short_channel_id_arg, byte[] node_signature_arg, byte[] bitcoin_signature_arg) {
                long ret = bindings.AnnouncementSignatures_new(channel_id_arg, short_channel_id_arg, node_signature_arg, bitcoin_signature_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               AnnouncementSignatures ret_hu_conv = new AnnouncementSignatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               AnnouncementSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new AnnouncementSignatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -95,8 +95,8 @@ public class AnnouncementSignatures extends CommonBase {
         */
        public AnnouncementSignatures clone() {
                long ret = bindings.AnnouncementSignatures_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               AnnouncementSignatures ret_hu_conv = new AnnouncementSignatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               AnnouncementSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new AnnouncementSignatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -114,7 +114,7 @@ public class AnnouncementSignatures extends CommonBase {
         */
        public static Result_AnnouncementSignaturesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.AnnouncementSignatures_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AnnouncementSignaturesDecodeErrorZ ret_hu_conv = Result_AnnouncementSignaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 3c2af93e3e56d7a6ae8e537c688a09cc25a79ca6..6f60b92d2623601fce3b9095d352cfbd22b73a78 100644 (file)
@@ -77,10 +77,10 @@ public class BackgroundProcessor extends CommonBase {
         * 
         * 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, NetGraphMsgHandler net_graph_msg_handler, PeerManager peer_manager, Logger logger) {
+       public static BackgroundProcessor start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, @Nullable 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 >= 0 && ret < 1024) { return null; }
-               BackgroundProcessor ret_hu_conv = new BackgroundProcessor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BackgroundProcessor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = 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);
@@ -105,7 +105,7 @@ public class BackgroundProcessor extends CommonBase {
         */
        public Result_NoneErrorZ join() {
                long ret = bindings.BackgroundProcessor_join(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(this);
                // Due to rust's strict-ownership memory model, in some cases we need to "move"
@@ -132,7 +132,7 @@ public class BackgroundProcessor extends CommonBase {
         */
        public Result_NoneErrorZ stop() {
                long ret = bindings.BackgroundProcessor_stop(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(this);
                // Due to rust's strict-ownership memory model, in some cases we need to "move"
index 107c8d093ebc6ed2817cb7c3773b3764156debb9..52d28898e2de9afd553febb0f18499d9f88ce657 100644 (file)
@@ -105,7 +105,7 @@ public class Balance extends CommonBase {
         */
        public Balance clone() {
                long ret = bindings.Balance_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Balance ret_hu_conv = Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -116,7 +116,7 @@ public class Balance extends CommonBase {
         */
        public static Balance claimable_on_channel_close(long claimable_amount_satoshis) {
                long ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Balance ret_hu_conv = Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -127,7 +127,7 @@ public class Balance extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Balance ret_hu_conv = Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -138,7 +138,7 @@ public class Balance extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Balance ret_hu_conv = Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -149,7 +149,7 @@ public class Balance extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Balance ret_hu_conv = Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 82561db04208cb0b8f9744581f2ce1519a7bc18d..b502674c740885f1cd262e2a184468c037a5dd61 100644 (file)
@@ -202,7 +202,7 @@ public class BaseSign extends CommonBase {
                                return ret;
                        }
                        @Override public long validate_holder_commitment(long holder_tx) {
-                               HolderCommitmentTransaction holder_tx_hu_conv = new HolderCommitmentTransaction(null, holder_tx);
+                               HolderCommitmentTransaction holder_tx_hu_conv = null; if (holder_tx < 0 || holder_tx > 4096) { 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;
@@ -212,7 +212,7 @@ public class BaseSign extends CommonBase {
                                return ret;
                        }
                        @Override public long sign_counterparty_commitment(long commitment_tx) {
-                               CommitmentTransaction commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx);
+                               CommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx); }
                                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
@@ -223,7 +223,7 @@ public class BaseSign extends CommonBase {
                                return result;
                        }
                        @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) {
-                               HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx);
+                               HolderCommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); }
                                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
@@ -234,31 +234,31 @@ public class BaseSign extends CommonBase {
                                return result;
                        }
                        @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) {
-                               HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc);
+                               HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); }
                                Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) {
-                               HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc);
+                               HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); }
                                Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long sign_closing_transaction(long closing_tx) {
-                               ClosingTransaction closing_tx_hu_conv = new ClosingTransaction(null, closing_tx);
+                               ClosingTransaction closing_tx_hu_conv = null; if (closing_tx < 0 || closing_tx > 4096) { 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;
                        }
                        @Override public long sign_channel_announcement(long msg) {
-                               UnsignedChannelAnnouncement msg_hu_conv = new UnsignedChannelAnnouncement(null, msg);
+                               UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UnsignedChannelAnnouncement(null, msg); }
                                Result_SignatureNoneZ ret = arg.sign_channel_announcement(msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public void ready_channel(long channel_parameters) {
-                               ChannelTransactionParameters channel_parameters_hu_conv = new ChannelTransactionParameters(null, channel_parameters);
+                               ChannelTransactionParameters channel_parameters_hu_conv = null; if (channel_parameters < 0 || channel_parameters > 4096) { channel_parameters_hu_conv = new ChannelTransactionParameters(null, channel_parameters); }
                                arg.ready_channel(channel_parameters_hu_conv);
                        }
                }, pubkeys);
@@ -299,7 +299,7 @@ public class BaseSign extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(holder_tx);
                return ret_hu_conv;
@@ -325,7 +325,7 @@ public class BaseSign extends CommonBase {
         */
        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);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(commitment_tx);
                return ret_hu_conv;
@@ -339,7 +339,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
                long ret = bindings.BaseSign_validate_counterparty_revocation(this.ptr, idx, secret);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -359,7 +359,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) {
                long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(commitment_tx);
                return ret_hu_conv;
@@ -383,7 +383,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
                long ret = bindings.BaseSign_sign_justice_revoked_output(this.ptr, justice_tx, input, amount, per_commitment_key);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -409,7 +409,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) {
                long ret = bindings.BaseSign_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, per_commitment_key, htlc == null ? 0 : htlc.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(htlc);
                return ret_hu_conv;
@@ -436,7 +436,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) {
                long ret = bindings.BaseSign_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, per_commitment_point, htlc == null ? 0 : htlc.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(htlc);
                return ret_hu_conv;
@@ -450,7 +450,7 @@ public class BaseSign extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(closing_tx);
                return ret_hu_conv;
@@ -466,7 +466,7 @@ public class BaseSign extends CommonBase {
         */
        public Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
                long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -495,8 +495,8 @@ public class BaseSign extends CommonBase {
         */
        public ChannelPublicKeys get_pubkeys() {
                long ret = bindings.BaseSign_get_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 9377da15b41062394d6870f6c23a4d4ee9e5e86c..9d3629ebe4c016a63fe31e4eff59802e69ef6118 100644 (file)
@@ -24,8 +24,8 @@ public class BestBlock extends CommonBase {
         */
        public BestBlock clone() {
                long ret = bindings.BestBlock_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -36,8 +36,8 @@ public class BestBlock extends CommonBase {
         */
        public static BestBlock from_genesis(org.ldk.enums.Network network) {
                long ret = bindings.BestBlock_from_genesis(network);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -47,8 +47,8 @@ public class BestBlock extends CommonBase {
         */
        public static BestBlock of(byte[] block_hash, int height) {
                long ret = bindings.BestBlock_new(block_hash, height);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
index 4921e1eb0d33712e897c0b8bb48bd4653681ee05..ba33bd311aa862ea253d11990f37cd2ee4cb0bb6 100644 (file)
@@ -60,8 +60,8 @@ public class BuiltCommitmentTransaction extends CommonBase {
         */
        public static BuiltCommitmentTransaction of(byte[] transaction_arg, byte[] txid_arg) {
                long ret = bindings.BuiltCommitmentTransaction_new(transaction_arg, txid_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -71,8 +71,8 @@ public class BuiltCommitmentTransaction extends CommonBase {
         */
        public BuiltCommitmentTransaction clone() {
                long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -90,7 +90,7 @@ public class BuiltCommitmentTransaction extends CommonBase {
         */
        public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
                long ret = bindings.BuiltCommitmentTransaction_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 69d1c7ca50570881a83a5c16f81fb993ccf43327..c3ccf961b96766344fa394a30743c9928c84f686 100644 (file)
@@ -38,8 +38,8 @@ public class ChainMonitor extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
-               ChainMonitor ret_hu_conv = new ChainMonitor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChainMonitor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChainMonitor(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(broadcaster);
                ret_hu_conv.ptrs_to.add(logger);
@@ -80,7 +80,7 @@ public class ChainMonitor extends CommonBase {
         */
        public Result_LockedChannelMonitorNoneZ get_monitor(OutPoint funding_txo) {
                long ret = bindings.ChainMonitor_get_monitor(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_LockedChannelMonitorNoneZ ret_hu_conv = Result_LockedChannelMonitorNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -96,20 +96,42 @@ public class ChainMonitor extends CommonBase {
                OutPoint[] ret_conv_10_arr = new OutPoint[ret.length];
                for (int k = 0; k < ret.length; k++) {
                        long ret_conv_10 = ret[k];
-                       OutPoint ret_conv_10_hu_conv = new OutPoint(null, ret_conv_10);
+                       OutPoint ret_conv_10_hu_conv = null; if (ret_conv_10 < 0 || ret_conv_10 > 4096) { ret_conv_10_hu_conv = new OutPoint(null, ret_conv_10); }
                        ret_conv_10_hu_conv.ptrs_to.add(this);
                        ret_conv_10_arr[k] = ret_conv_10_hu_conv;
                }
                return ret_conv_10_arr;
        }
 
+       /**
+        * Indicates the persistence of a [`ChannelMonitor`] has completed after
+        * [`ChannelMonitorUpdateErr::TemporaryFailure`] was returned from an update operation.
+        * 
+        * Thus, the anticipated use is, at a high level:
+        * 1) This [`ChainMonitor`] calls [`Persist::update_persisted_channel`] which stores the
+        * update to disk and begins updating any remote (e.g. watchtower/backup) copies,
+        * returning [`ChannelMonitorUpdateErr::TemporaryFailure`],
+        * 2) once all remote copies are updated, you call this function with the
+        * `completed_update_id` that completed, and once all pending updates have completed the
+        * channel will be re-enabled.
+        * 
+        * Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently
+        * registered [`ChannelMonitor`]s.
+        */
+       public Result_NoneAPIErrorZ channel_monitor_updated(OutPoint funding_txo, MonitorUpdateId completed_update_id) {
+               long ret = bindings.ChainMonitor_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, completed_update_id == null ? 0 : completed_update_id.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
        /**
         * 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
         */
        public Listen as_Listen() {
                long ret = bindings.ChainMonitor_as_Listen(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Listen ret_hu_conv = new Listen(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -121,7 +143,7 @@ public class ChainMonitor extends CommonBase {
         */
        public Confirm as_Confirm() {
                long ret = bindings.ChainMonitor_as_Confirm(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Confirm ret_hu_conv = new Confirm(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -133,7 +155,7 @@ public class ChainMonitor extends CommonBase {
         */
        public Watch as_Watch() {
                long ret = bindings.ChainMonitor_as_Watch(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Watch ret_hu_conv = new Watch(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -145,7 +167,7 @@ public class ChainMonitor extends CommonBase {
         */
        public EventsProvider as_EventsProvider() {
                long ret = bindings.ChainMonitor_as_EventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                EventsProvider ret_hu_conv = new EventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 48f54722ae88aab10ab72eac28ed3825a88ad578..403a4d36236a28ff0d17ed6dd606176705b20ed2 100644 (file)
@@ -45,8 +45,8 @@ public class ChainParameters extends CommonBase {
         */
        public BestBlock get_best_block() {
                long ret = bindings.ChainParameters_get_best_block(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -65,8 +65,8 @@ public class ChainParameters extends CommonBase {
         */
        public static ChainParameters of(org.ldk.enums.Network network_arg, BestBlock best_block_arg) {
                long ret = bindings.ChainParameters_new(network_arg, best_block_arg == null ? 0 : best_block_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChainParameters ret_hu_conv = new ChainParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChainParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -76,8 +76,8 @@ public class ChainParameters extends CommonBase {
         */
        public ChainParameters clone() {
                long ret = bindings.ChainParameters_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChainParameters ret_hu_conv = new ChainParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChainParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChainParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 7653ceba2eb1ac9eececf6007525a2c838d46ea6..808d0a679b0488ec01c0b87310d3c4ac434d0de8 100644 (file)
@@ -84,8 +84,8 @@ public class ChannelAnnouncement extends CommonBase {
         */
        public UnsignedChannelAnnouncement get_contents() {
                long ret = bindings.ChannelAnnouncement_get_contents(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -102,8 +102,8 @@ public class ChannelAnnouncement extends CommonBase {
         */
        public static ChannelAnnouncement of(byte[] node_signature_1_arg, byte[] node_signature_2_arg, byte[] bitcoin_signature_1_arg, byte[] bitcoin_signature_2_arg, UnsignedChannelAnnouncement contents_arg) {
                long ret = bindings.ChannelAnnouncement_new(node_signature_1_arg, node_signature_2_arg, bitcoin_signature_1_arg, bitcoin_signature_2_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -113,8 +113,8 @@ public class ChannelAnnouncement extends CommonBase {
         */
        public ChannelAnnouncement clone() {
                long ret = bindings.ChannelAnnouncement_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -132,7 +132,7 @@ public class ChannelAnnouncement extends CommonBase {
         */
        public static Result_ChannelAnnouncementDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelAnnouncement_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 820d870ef2ebd8751270737f29f9af0694a312c4..c1ec909fe7812789a83660bc9bea54eba679cb92 100644 (file)
@@ -308,8 +308,8 @@ public class ChannelConfig extends CommonBase {
         */
        public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg, long max_dust_htlc_exposure_msat_arg, long force_close_avoidance_max_fee_satoshis_arg) {
                long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -319,8 +319,8 @@ public class ChannelConfig extends CommonBase {
         */
        public ChannelConfig clone() {
                long ret = bindings.ChannelConfig_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -330,8 +330,8 @@ public class ChannelConfig extends CommonBase {
         */
        public static ChannelConfig with_default() {
                long ret = bindings.ChannelConfig_default();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -349,7 +349,7 @@ public class ChannelConfig extends CommonBase {
         */
        public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelConfig_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index ad25abaddf0c1e52e5a6a898bcb67e047020ea21..db770c86498631aafcb497caee8172a2fa2a11f7 100644 (file)
@@ -42,8 +42,8 @@ public class ChannelCounterparty extends CommonBase {
         */
        public InitFeatures get_features() {
                long ret = bindings.ChannelCounterparty_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InitFeatures ret_hu_conv = new InitFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -93,8 +93,8 @@ public class ChannelCounterparty extends CommonBase {
        @Nullable
        public CounterpartyForwardingInfo get_forwarding_info() {
                long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyForwardingInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -114,8 +114,8 @@ public class ChannelCounterparty extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
-               ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -125,8 +125,8 @@ public class ChannelCounterparty extends CommonBase {
         */
        public ChannelCounterparty clone() {
                long ret = bindings.ChannelCounterparty_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 878fe31af1061b1a309ce46f3ab6e5be6f5b2e49..75db7b25dd55d1087d4ed8d1bcff2e5ee2c855fd 100644 (file)
@@ -45,8 +45,8 @@ public class ChannelDetails extends CommonBase {
         */
        public ChannelCounterparty get_counterparty() {
                long ret = bindings.ChannelDetails_get_counterparty(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -70,8 +70,8 @@ public class ChannelDetails extends CommonBase {
        @Nullable
        public OutPoint get_funding_txo() {
                long ret = bindings.ChannelDetails_get_funding_txo(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -95,7 +95,7 @@ public class ChannelDetails extends CommonBase {
         */
        public Option_u64Z get_short_channel_id() {
                long ret = bindings.ChannelDetails_get_short_channel_id(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -137,7 +137,7 @@ public class ChannelDetails extends CommonBase {
         */
        public Option_u64Z get_unspendable_punishment_reserve() {
                long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -248,7 +248,7 @@ public class ChannelDetails extends CommonBase {
         */
        public Option_u32Z get_confirmations_required() {
                long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -282,7 +282,7 @@ public class ChannelDetails extends CommonBase {
         */
        public Option_u16Z get_force_close_spend_delay() {
                long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -384,8 +384,8 @@ public class ChannelDetails extends CommonBase {
         */
        public static ChannelDetails of(byte[] channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, Option_u64Z short_channel_id_arg, long channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, long user_channel_id_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) {
                long ret = bindings.ChannelDetails_new(channel_id_arg, counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, short_channel_id_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelDetails ret_hu_conv = new ChannelDetails(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -395,8 +395,8 @@ public class ChannelDetails extends CommonBase {
         */
        public ChannelDetails clone() {
                long ret = bindings.ChannelDetails_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelDetails ret_hu_conv = new ChannelDetails(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelDetails ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelDetails(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 296278416cda8d6f710ec8010d56da57f0dd93f5..79e9c605d6e09e3973487e1abac2ad842c3a8a1d 100644 (file)
@@ -35,8 +35,8 @@ public class ChannelFeatures extends CommonBase {
         */
        public ChannelFeatures clone() {
                long ret = bindings.ChannelFeatures_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -46,8 +46,8 @@ public class ChannelFeatures extends CommonBase {
         */
        public static ChannelFeatures empty() {
                long ret = bindings.ChannelFeatures_empty();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class ChannelFeatures extends CommonBase {
         */
        public static ChannelFeatures known() {
                long ret = bindings.ChannelFeatures_known();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -85,7 +85,7 @@ public class ChannelFeatures extends CommonBase {
         */
        public static Result_ChannelFeaturesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelFeatures_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8f9fb17b34b3de5b8107e2fec8fa3bcfe1da4d9b..e4b3e944ffe9afbb5e4042e99bc7a647844d03d0 100644 (file)
@@ -119,8 +119,8 @@ public class ChannelHandshakeConfig extends CommonBase {
         */
        public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg) {
                long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -130,8 +130,8 @@ public class ChannelHandshakeConfig extends CommonBase {
         */
        public ChannelHandshakeConfig clone() {
                long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -141,8 +141,8 @@ public class ChannelHandshakeConfig extends CommonBase {
         */
        public static ChannelHandshakeConfig with_default() {
                long ret = bindings.ChannelHandshakeConfig_default();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
index 06e9432b9e92de810ed56b98623bba783f6372ae..b54ed69f673b20c9264c2d3d0c42364e66136296 100644 (file)
@@ -222,8 +222,8 @@ public class ChannelHandshakeLimits extends CommonBase {
         */
        public static ChannelHandshakeLimits of(long min_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, int max_minimum_depth_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) {
                long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -233,8 +233,8 @@ public class ChannelHandshakeLimits extends CommonBase {
         */
        public ChannelHandshakeLimits clone() {
                long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -244,8 +244,8 @@ public class ChannelHandshakeLimits extends CommonBase {
         */
        public static ChannelHandshakeLimits with_default() {
                long ret = bindings.ChannelHandshakeLimits_default();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
index 5266faed26b3def1eb3bc47bda000ad906f7ca93..c351b05271f4e14703596e03c3df9c79b650223c 100644 (file)
@@ -25,8 +25,8 @@ public class ChannelInfo extends CommonBase {
         */
        public ChannelFeatures get_features() {
                long ret = bindings.ChannelInfo_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -43,8 +43,8 @@ public class ChannelInfo extends CommonBase {
         */
        public NodeId get_node_one() {
                long ret = bindings.ChannelInfo_get_node_one(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeId ret_hu_conv = new NodeId(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -64,8 +64,8 @@ public class ChannelInfo extends CommonBase {
        @Nullable
        public DirectionalChannelInfo get_one_to_two() {
                long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,8 +84,8 @@ public class ChannelInfo extends CommonBase {
         */
        public NodeId get_node_two() {
                long ret = bindings.ChannelInfo_get_node_two(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeId ret_hu_conv = new NodeId(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -105,8 +105,8 @@ public class ChannelInfo extends CommonBase {
        @Nullable
        public DirectionalChannelInfo get_two_to_one() {
                long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -125,7 +125,7 @@ public class ChannelInfo extends CommonBase {
         */
        public Option_u64Z get_capacity_sats() {
                long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -149,8 +149,8 @@ public class ChannelInfo extends CommonBase {
        @Nullable
        public ChannelAnnouncement get_announcement_message() {
                long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -172,8 +172,8 @@ public class ChannelInfo extends CommonBase {
         */
        public static ChannelInfo of(ChannelFeatures features_arg, NodeId node_one_arg, DirectionalChannelInfo one_to_two_arg, NodeId node_two_arg, DirectionalChannelInfo two_to_one_arg, Option_u64Z capacity_sats_arg, ChannelAnnouncement announcement_message_arg) {
                long ret = bindings.ChannelInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, node_one_arg == null ? 0 : node_one_arg.ptr & ~1, one_to_two_arg == null ? 0 : one_to_two_arg.ptr & ~1, node_two_arg == null ? 0 : node_two_arg.ptr & ~1, two_to_one_arg == null ? 0 : two_to_one_arg.ptr & ~1, capacity_sats_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -183,8 +183,8 @@ public class ChannelInfo extends CommonBase {
         */
        public ChannelInfo clone() {
                long ret = bindings.ChannelInfo_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelInfo ret_hu_conv = new ChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -202,7 +202,7 @@ public class ChannelInfo extends CommonBase {
         */
        public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelInfo_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9359cfb836791ac7181b0efb3deb3d7d915f9771..121809b064fa6ea7d16172072f09963048752758 100644 (file)
@@ -70,8 +70,8 @@ public class ChannelManager extends CommonBase {
         */
        public static ChannelManager of(FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, ChainParameters params) {
                long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr & ~1, params == null ? 0 : params.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelManager ret_hu_conv = new ChannelManager(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelManager(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(fee_est);
                ret_hu_conv.ptrs_to.add(chain_monitor);
@@ -86,8 +86,8 @@ public class ChannelManager extends CommonBase {
         */
        public UserConfig get_current_default_configuration() {
                long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UserConfig ret_hu_conv = new UserConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -124,7 +124,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result__u832APIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_channel_id, @Nullable UserConfig override_config) {
                long ret = bindings.ChannelManager_create_channel(this.ptr, their_network_key, channel_value_satoshis, push_msat, user_channel_id, override_config == null ? 0 : override_config.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -138,7 +138,7 @@ public class ChannelManager extends CommonBase {
                ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
                for (int q = 0; q < ret.length; q++) {
                        long ret_conv_16 = ret[q];
-                       ChannelDetails ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16);
+                       ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16); }
                        ret_conv_16_hu_conv.ptrs_to.add(this);
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
@@ -158,7 +158,7 @@ public class ChannelManager extends CommonBase {
                ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
                for (int q = 0; q < ret.length; q++) {
                        long ret_conv_16 = ret[q];
-                       ChannelDetails ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16);
+                       ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16); }
                        ret_conv_16_hu_conv.ptrs_to.add(this);
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
@@ -186,7 +186,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_NoneAPIErrorZ close_channel(byte[] channel_id) {
                long ret = bindings.ChannelManager_close_channel(this.ptr, channel_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -214,7 +214,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_NoneAPIErrorZ close_channel_with_target_feerate(byte[] channel_id, int target_feerate_sats_per_1000_weight) {
                long ret = bindings.ChannelManager_close_channel_with_target_feerate(this.ptr, channel_id, target_feerate_sats_per_1000_weight);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -225,7 +225,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_NoneAPIErrorZ force_close_channel(byte[] channel_id) {
                long ret = bindings.ChannelManager_force_close_channel(this.ptr, channel_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -283,7 +283,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, @Nullable byte[] payment_secret) {
                long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_hash, payment_secret);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
                this.ptrs_to.add(route);
                return ret_hu_conv;
@@ -299,9 +299,9 @@ public class ChannelManager extends CommonBase {
         * 
         * [`send_payment`]: [`ChannelManager::send_payment`]
         */
-       public Result_NonePaymentSendFailureZ retry_payment(Route route, PaymentId payment_id) {
-               long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id == null ? 0 : payment_id.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id) {
+               long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                this.ptrs_to.add(route);
                return ret_hu_conv;
@@ -327,7 +327,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_spontaneous_payment(Route route, @Nullable byte[] payment_preimage) {
                long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_preimage);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
                this.ptrs_to.add(route);
                return ret_hu_conv;
@@ -357,7 +357,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] funding_transaction) {
                long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, temporary_channel_id, funding_transaction);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -452,33 +452,6 @@ public class ChannelManager extends CommonBase {
                return ret;
        }
 
-       /**
-        * Restores a single, given channel to normal operation after a
-        * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
-        * operation.
-        * 
-        * All ChannelMonitor updates up to and including highest_applied_update_id must have been
-        * fully committed in every copy of the given channels' ChannelMonitors.
-        * 
-        * Note that there is no effect to calling with a highest_applied_update_id other than the
-        * current latest ChannelMonitorUpdate and one call to this function after multiple
-        * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
-        * exists largely only to prevent races between this and concurrent update_monitor calls.
-        * 
-        * Thus, the anticipated use is, at a high level:
-        * 1) You register a chain::Watch with this ChannelManager,
-        * 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
-        * said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
-        * any time it cannot do so instantly,
-        * 3) update(s) are applied to each remote copy of a ChannelMonitor,
-        * 4) once all remote copies are updated, you call this function with the update_id that
-        * completed, and once it is the latest the Channel will be re-enabled.
-        */
-       public void channel_monitor_updated(OutPoint funding_txo, long highest_applied_update_id) {
-               bindings.ChannelManager_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, highest_applied_update_id);
-               this.ptrs_to.add(funding_txo);
-       }
-
        /**
         * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
         * to pay us.
@@ -499,7 +472,7 @@ public class ChannelManager extends CommonBase {
         */
        public TwoTuple_PaymentHashPaymentSecretZ create_inbound_payment(Option_u64Z min_value_msat, int invoice_expiry_delta_secs, long user_payment_id) {
                long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, user_payment_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PaymentHashPaymentSecretZ ret_hu_conv = new TwoTuple_PaymentHashPaymentSecretZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -554,7 +527,7 @@ public class ChannelManager extends CommonBase {
         */
        public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash(byte[] payment_hash, Option_u64Z min_value_msat, int invoice_expiry_delta_secs, long user_payment_id) {
                long ret = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, payment_hash, min_value_msat.ptr, invoice_expiry_delta_secs, user_payment_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -565,7 +538,7 @@ public class ChannelManager extends CommonBase {
         */
        public MessageSendEventsProvider as_MessageSendEventsProvider() {
                long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -577,7 +550,7 @@ public class ChannelManager extends CommonBase {
         */
        public EventsProvider as_EventsProvider() {
                long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                EventsProvider ret_hu_conv = new EventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -589,7 +562,7 @@ public class ChannelManager extends CommonBase {
         */
        public Listen as_Listen() {
                long ret = bindings.ChannelManager_as_Listen(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Listen ret_hu_conv = new Listen(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -601,7 +574,7 @@ public class ChannelManager extends CommonBase {
         */
        public Confirm as_Confirm() {
                long ret = bindings.ChannelManager_as_Confirm(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Confirm ret_hu_conv = new Confirm(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -634,8 +607,8 @@ public class ChannelManager extends CommonBase {
         */
        public BestBlock current_best_block() {
                long ret = bindings.ChannelManager_current_best_block(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -646,7 +619,7 @@ public class ChannelManager extends CommonBase {
         */
        public ChannelMessageHandler as_ChannelMessageHandler() {
                long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -660,4 +633,16 @@ public class ChannelManager extends CommonBase {
                return ret;
        }
 
+       /**
+        * Constructs a new Payer which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned Payer must be freed before this_arg is
+        */
+       public Payer as_Payer() {
+               long ret = bindings.ChannelManager_as_Payer(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payer ret_hu_conv = new Payer(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index 2030e473727c26b4545df28ae4b8e4421a4654cd..cac176ade7a83df977aa60c51faa327b5a790706 100644 (file)
@@ -39,7 +39,7 @@ public class ChannelManagerPersister extends CommonBase {
                final LDKChannelManagerPersisterHolder impl_holder = new LDKChannelManagerPersisterHolder();
                impl_holder.held = new ChannelManagerPersister(new bindings.LDKChannelManagerPersister() {
                        @Override public long persist_manager(long channel_manager) {
-                               ChannelManager channel_manager_hu_conv = new ChannelManager(null, channel_manager);
+                               ChannelManager channel_manager_hu_conv = null; if (channel_manager < 0 || channel_manager > 4096) { channel_manager_hu_conv = new ChannelManager(null, channel_manager); }
                                Result_NoneErrorZ ret = arg.persist_manager(channel_manager_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
@@ -55,7 +55,7 @@ public class ChannelManagerPersister extends CommonBase {
         */
        public Result_NoneErrorZ persist_manager(ChannelManager channel_manager) {
                long ret = bindings.ChannelManagerPersister_persist_manager(this.ptr, channel_manager == null ? 0 : channel_manager.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(channel_manager);
                return ret_hu_conv;
index 5298b8a2b6876f17dad250b5b4faa4af8d170f8c..2d628226cd64376a6c5b460c8f303762d67334e6 100644 (file)
@@ -12,20 +12,25 @@ import javax.annotation.Nullable;
  * 
  * At a high-level, the process for deserializing a ChannelManager and resuming normal operation
  * is:
- * 1) Deserialize all stored ChannelMonitors.
- * 2) Deserialize the ChannelManager by filling in this struct and calling:
- * <(BlockHash, ChannelManager)>::read(reader, args)
- * This may result in closing some Channels if the ChannelMonitor is newer than the stored
- * ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
- * 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same
- * way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and
- * ChannelMonitor::get_funding_txo().
- * 4) Reconnect blocks on your ChannelMonitors.
- * 5) Disconnect/connect blocks on the ChannelManager.
- * 6) Move the ChannelMonitors into your local chain::Watch.
+ * 1) Deserialize all stored [`ChannelMonitor`]s.
+ * 2) Deserialize the [`ChannelManager`] by filling in this struct and calling:
+ * `<(BlockHash, ChannelManager)>::read(reader, args)`
+ * This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored
+ * [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted.
+ * 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the
+ * same way you would handle a [`chain::Filter`] call using
+ * [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`].
+ * 4) Reconnect blocks on your [`ChannelMonitor`]s.
+ * 5) Disconnect/connect blocks on the [`ChannelManager`].
+ * 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk.
+ * Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you
+ * will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in
+ * the next step.
+ * 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a
+ * [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`].
  * 
- * Note that the ordering of #4-6 is not of importance, however all three must occur before you
- * call any other methods on the newly-deserialized ChannelManager.
+ * Note that the ordering of #4-7 is not of importance, however all four must occur before you
+ * call any other methods on the newly-deserialized [`ChannelManager`].
  * 
  * Note that because some channels may be closed during deserialization, it is critical that you
  * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
@@ -33,6 +38,8 @@ import javax.annotation.Nullable;
  * broadcast), and then later deserialize a newer version of the same ChannelManager (which will
  * not force-close the same channels but consider them live), you may end up revoking a state for
  * which you've already broadcasted the transaction.
+ * 
+ * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class ChannelManagerReadArgs extends CommonBase {
@@ -50,7 +57,7 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public KeysInterface get_keys_manager() {
                long ret = bindings.ChannelManagerReadArgs_get_keys_manager(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                KeysInterface ret_hu_conv = new KeysInterface(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -73,7 +80,7 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public FeeEstimator get_fee_estimator() {
                long ret = bindings.ChannelManagerReadArgs_get_fee_estimator(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                FeeEstimator ret_hu_conv = new FeeEstimator(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -98,7 +105,7 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public Watch get_chain_monitor() {
                long ret = bindings.ChannelManagerReadArgs_get_chain_monitor(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Watch ret_hu_conv = new Watch(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -123,7 +130,7 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public BroadcasterInterface get_tx_broadcaster() {
                long ret = bindings.ChannelManagerReadArgs_get_tx_broadcaster(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                BroadcasterInterface ret_hu_conv = new BroadcasterInterface(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -145,7 +152,7 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public Logger get_logger() {
                long ret = bindings.ChannelManagerReadArgs_get_logger(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Logger ret_hu_conv = new Logger(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -166,8 +173,8 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public UserConfig get_default_config() {
                long ret = bindings.ChannelManagerReadArgs_get_default_config(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UserConfig ret_hu_conv = new UserConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -187,8 +194,8 @@ public class ChannelManagerReadArgs extends CommonBase {
         */
        public static ChannelManagerReadArgs of(KeysInterface keys_manager, FeeEstimator fee_estimator, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, UserConfig default_config, ChannelMonitor[] channel_monitors) {
                long ret = bindings.ChannelManagerReadArgs_new(keys_manager == null ? 0 : keys_manager.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, default_config == null ? 0 : default_config.ptr & ~1, channel_monitors != null ? Arrays.stream(channel_monitors).mapToLong(channel_monitors_conv_16 -> channel_monitors_conv_16 == null ? 0 : channel_monitors_conv_16.ptr & ~1).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelManagerReadArgs ret_hu_conv = new ChannelManagerReadArgs(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelManagerReadArgs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelManagerReadArgs(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(keys_manager);
                ret_hu_conv.ptrs_to.add(fee_estimator);
index 190789dbe2c85575b5a6d352df5c051b6b1d4aa0..c6604d115130af0d2df7e6dc61b2a3b5003ecf42 100644 (file)
@@ -117,87 +117,87 @@ public class ChannelMessageHandler extends CommonBase {
                final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder();
                impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() {
                        @Override public void handle_open_channel(byte[] their_node_id, long their_features, long msg) {
-                               InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
+                               InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new InitFeatures(null, their_features); }
                                their_features_hu_conv.ptrs_to.add(this);
-                               OpenChannel msg_hu_conv = new OpenChannel(null, msg);
+                               OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new OpenChannel(null, msg); }
                                arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
                        }
                        @Override public void handle_accept_channel(byte[] their_node_id, long their_features, long msg) {
-                               InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
+                               InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new InitFeatures(null, their_features); }
                                their_features_hu_conv.ptrs_to.add(this);
-                               AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
+                               AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AcceptChannel(null, msg); }
                                arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv);
                        }
                        @Override public void handle_funding_created(byte[] their_node_id, long msg) {
-                               FundingCreated msg_hu_conv = new FundingCreated(null, msg);
+                               FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingCreated(null, msg); }
                                arg.handle_funding_created(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_funding_signed(byte[] their_node_id, long msg) {
-                               FundingSigned msg_hu_conv = new FundingSigned(null, msg);
+                               FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingSigned(null, msg); }
                                arg.handle_funding_signed(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_funding_locked(byte[] their_node_id, long msg) {
-                               FundingLocked msg_hu_conv = new FundingLocked(null, msg);
+                               FundingLocked msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingLocked(null, msg); }
                                arg.handle_funding_locked(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_shutdown(byte[] their_node_id, long their_features, long msg) {
-                               InitFeatures their_features_hu_conv = new InitFeatures(null, their_features);
-                               Shutdown msg_hu_conv = new Shutdown(null, msg);
+                               InitFeatures their_features_hu_conv = null; if (their_features < 0 || their_features > 4096) { their_features_hu_conv = new InitFeatures(null, their_features); }
+                               Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new Shutdown(null, msg); }
                                arg.handle_shutdown(their_node_id, their_features_hu_conv, msg_hu_conv);
                        }
                        @Override public void handle_closing_signed(byte[] their_node_id, long msg) {
-                               ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
+                               ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ClosingSigned(null, msg); }
                                arg.handle_closing_signed(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_update_add_htlc(byte[] their_node_id, long msg) {
-                               UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg);
+                               UpdateAddHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UpdateAddHTLC(null, msg); }
                                arg.handle_update_add_htlc(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_update_fulfill_htlc(byte[] their_node_id, long msg) {
-                               UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg);
+                               UpdateFulfillHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UpdateFulfillHTLC(null, msg); }
                                arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_update_fail_htlc(byte[] their_node_id, long msg) {
-                               UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg);
+                               UpdateFailHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UpdateFailHTLC(null, msg); }
                                arg.handle_update_fail_htlc(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, long msg) {
-                               UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg);
+                               UpdateFailMalformedHTLC msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UpdateFailMalformedHTLC(null, msg); }
                                arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_commitment_signed(byte[] their_node_id, long msg) {
-                               CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg);
+                               CommitmentSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new CommitmentSigned(null, msg); }
                                arg.handle_commitment_signed(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_revoke_and_ack(byte[] their_node_id, long msg) {
-                               RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
+                               RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new RevokeAndACK(null, msg); }
                                arg.handle_revoke_and_ack(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_update_fee(byte[] their_node_id, long msg) {
-                               UpdateFee msg_hu_conv = new UpdateFee(null, msg);
+                               UpdateFee msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UpdateFee(null, msg); }
                                arg.handle_update_fee(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_announcement_signatures(byte[] their_node_id, long msg) {
-                               AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
+                               AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AnnouncementSignatures(null, msg); }
                                arg.handle_announcement_signatures(their_node_id, msg_hu_conv);
                        }
                        @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) {
                                arg.peer_disconnected(their_node_id, no_connection_possible);
                        }
                        @Override public void peer_connected(byte[] their_node_id, long msg) {
-                               Init msg_hu_conv = new Init(null, msg);
+                               Init msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new Init(null, msg); }
                                arg.peer_connected(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_channel_reestablish(byte[] their_node_id, long msg) {
-                               ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
+                               ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelReestablish(null, msg); }
                                arg.handle_channel_reestablish(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_channel_update(byte[] their_node_id, long msg) {
-                               ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                               ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                                arg.handle_channel_update(their_node_id, msg_hu_conv);
                        }
                        @Override public void handle_error(byte[] their_node_id, long msg) {
-                               ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
+                               ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
                                arg.handle_error(their_node_id, msg_hu_conv);
                        }
                }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance);
index ab7b76910d330e204a5f6fe4a9f279fb066afa24..3e3f9f0dda4ee47fe6f047b8da593aad55df8a4a 100644 (file)
@@ -39,8 +39,8 @@ public class ChannelMonitor extends CommonBase {
         */
        public ChannelMonitor clone() {
                long ret = bindings.ChannelMonitor_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelMonitor ret_hu_conv = new ChannelMonitor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelMonitor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelMonitor(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -61,7 +61,7 @@ public class ChannelMonitor extends CommonBase {
         */
        public Result_NoneMonitorUpdateErrorZ update_monitor(ChannelMonitorUpdate updates, BroadcasterInterface broadcaster, FeeEstimator fee_estimator, Logger logger) {
                long ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates == null ? 0 : updates.ptr & ~1, broadcaster == null ? 0 : broadcaster.ptr, fee_estimator == null ? 0 : fee_estimator.ptr, logger == null ? 0 : logger.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(updates);
                this.ptrs_to.add(broadcaster);
@@ -84,7 +84,7 @@ public class ChannelMonitor extends CommonBase {
         */
        public TwoTuple_OutPointScriptZ get_funding_txo() {
                long ret = bindings.ChannelMonitor_get_funding_txo(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_OutPointScriptZ ret_hu_conv = new TwoTuple_OutPointScriptZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -285,8 +285,8 @@ public class ChannelMonitor extends CommonBase {
         */
        public BestBlock current_best_block() {
                long ret = bindings.ChannelMonitor_current_best_block(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BestBlock ret_hu_conv = new BestBlock(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 43ed1326d6b42adbd3cfa912671e59972366911d..2f4d00a5a2ef552295a56665e87343ed33875201 100644 (file)
@@ -60,8 +60,8 @@ public class ChannelMonitorUpdate extends CommonBase {
         */
        public ChannelMonitorUpdate clone() {
                long ret = bindings.ChannelMonitorUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelMonitorUpdate ret_hu_conv = new ChannelMonitorUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelMonitorUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelMonitorUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -79,7 +79,7 @@ public class ChannelMonitorUpdate extends CommonBase {
         */
        public static Result_ChannelMonitorUpdateDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelMonitorUpdate_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelMonitorUpdateDecodeErrorZ ret_hu_conv = Result_ChannelMonitorUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 84a1d7e8ebe7eeff890506d8fcb433848b005be2..2d98499be413b7c47652bac4f634d731a278d2ed 100644 (file)
@@ -117,8 +117,8 @@ public class ChannelPublicKeys extends CommonBase {
         */
        public static ChannelPublicKeys of(byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg) {
                long ret = bindings.ChannelPublicKeys_new(funding_pubkey_arg, revocation_basepoint_arg, payment_point_arg, delayed_payment_basepoint_arg, htlc_basepoint_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -128,8 +128,8 @@ public class ChannelPublicKeys extends CommonBase {
         */
        public ChannelPublicKeys clone() {
                long ret = bindings.ChannelPublicKeys_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -147,7 +147,7 @@ public class ChannelPublicKeys extends CommonBase {
         */
        public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelPublicKeys_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 914c8acc59c4ed2a640be67e4a218745faa84dbf..cf589693f792f444c51303f0f1a1076b551ce19c 100644 (file)
@@ -69,8 +69,8 @@ public class ChannelReestablish extends CommonBase {
         */
        public ChannelReestablish clone() {
                long ret = bindings.ChannelReestablish_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelReestablish ret_hu_conv = new ChannelReestablish(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelReestablish ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelReestablish(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -88,7 +88,7 @@ public class ChannelReestablish extends CommonBase {
         */
        public static Result_ChannelReestablishDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelReestablish_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c22941e929bcff8079eb624a91a7d67ae7ed142a..3145a4f14848ade67006bc66f820a027caaeee4b 100644 (file)
@@ -28,8 +28,8 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public ChannelPublicKeys get_holder_pubkeys() {
                long ret = bindings.ChannelTransactionParameters_get_holder_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -82,8 +82,8 @@ public class ChannelTransactionParameters extends CommonBase {
        @Nullable
        public CounterpartyChannelTransactionParameters get_counterparty_parameters() {
                long ret = bindings.ChannelTransactionParameters_get_counterparty_parameters(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CounterpartyChannelTransactionParameters ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -106,8 +106,8 @@ public class ChannelTransactionParameters extends CommonBase {
        @Nullable
        public OutPoint get_funding_outpoint() {
                long ret = bindings.ChannelTransactionParameters_get_funding_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -126,8 +126,8 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public static ChannelTransactionParameters of(ChannelPublicKeys holder_pubkeys_arg, short holder_selected_contest_delay_arg, boolean is_outbound_from_holder_arg, CounterpartyChannelTransactionParameters counterparty_parameters_arg, OutPoint funding_outpoint_arg) {
                long ret = bindings.ChannelTransactionParameters_new(holder_pubkeys_arg == null ? 0 : holder_pubkeys_arg.ptr & ~1, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg == null ? 0 : counterparty_parameters_arg.ptr & ~1, funding_outpoint_arg == null ? 0 : funding_outpoint_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -137,8 +137,8 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public ChannelTransactionParameters clone() {
                long ret = bindings.ChannelTransactionParameters_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -159,8 +159,8 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public DirectedChannelTransactionParameters as_holder_broadcastable() {
                long ret = bindings.ChannelTransactionParameters_as_holder_broadcastable(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectedChannelTransactionParameters ret_hu_conv = new DirectedChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -173,8 +173,8 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public DirectedChannelTransactionParameters as_counterparty_broadcastable() {
                long ret = bindings.ChannelTransactionParameters_as_counterparty_broadcastable(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectedChannelTransactionParameters ret_hu_conv = new DirectedChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectedChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectedChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -192,7 +192,7 @@ public class ChannelTransactionParameters extends CommonBase {
         */
        public static Result_ChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelTransactionParameters_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 13afaffc4c5560c0b9c6f87d7e58f6ddea90cdc2..1f0f43b19688ece56b8419b948b2bf46087e57a6 100644 (file)
@@ -39,8 +39,8 @@ public class ChannelUpdate extends CommonBase {
         */
        public UnsignedChannelUpdate get_contents() {
                long ret = bindings.ChannelUpdate_get_contents(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedChannelUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class ChannelUpdate extends CommonBase {
         */
        public static ChannelUpdate of(byte[] signature_arg, UnsignedChannelUpdate contents_arg) {
                long ret = bindings.ChannelUpdate_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -68,8 +68,8 @@ public class ChannelUpdate extends CommonBase {
         */
        public ChannelUpdate clone() {
                long ret = bindings.ChannelUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -87,7 +87,7 @@ public class ChannelUpdate extends CommonBase {
         */
        public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ChannelUpdate_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a3af4acd4bbca90e646142200b0b27a3650cda37..a7fb48ba6a0e87dd0b6ab963efa6a6edb6c7cf6d 100644 (file)
@@ -73,8 +73,8 @@ public class ClosingSigned extends CommonBase {
        @Nullable
        public ClosingSignedFeeRange get_fee_range() {
                long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ClosingSignedFeeRange ret_hu_conv = new ClosingSignedFeeRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSignedFeeRange(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -94,8 +94,8 @@ public class ClosingSigned extends CommonBase {
         */
        public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, ClosingSignedFeeRange fee_range_arg) {
                long ret = bindings.ClosingSigned_new(channel_id_arg, fee_satoshis_arg, signature_arg, fee_range_arg == null ? 0 : fee_range_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ClosingSigned ret_hu_conv = new ClosingSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -105,8 +105,8 @@ public class ClosingSigned extends CommonBase {
         */
        public ClosingSigned clone() {
                long ret = bindings.ClosingSigned_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ClosingSigned ret_hu_conv = new ClosingSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -124,7 +124,7 @@ public class ClosingSigned extends CommonBase {
         */
        public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ClosingSigned_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 04b5d8c7bc7eba567f0304f9b1865215a6c08688..6f4e79c1d8571f76d073baffae95995726f1e313 100644 (file)
@@ -60,8 +60,8 @@ public class ClosingSignedFeeRange extends CommonBase {
         */
        public static ClosingSignedFeeRange of(long min_fee_satoshis_arg, long max_fee_satoshis_arg) {
                long ret = bindings.ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ClosingSignedFeeRange ret_hu_conv = new ClosingSignedFeeRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSignedFeeRange(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -71,8 +71,8 @@ public class ClosingSignedFeeRange extends CommonBase {
         */
        public ClosingSignedFeeRange clone() {
                long ret = bindings.ClosingSignedFeeRange_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ClosingSignedFeeRange ret_hu_conv = new ClosingSignedFeeRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingSignedFeeRange(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -90,7 +90,7 @@ public class ClosingSignedFeeRange extends CommonBase {
         */
        public static Result_ClosingSignedFeeRangeDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ClosingSignedFeeRange_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedFeeRangeDecodeErrorZ ret_hu_conv = Result_ClosingSignedFeeRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index e08a432f05ad9e4744f03c86daf04d02e76acc6f..198d2a489de0c05a7394fcaa8e2073462307ba70 100644 (file)
@@ -23,13 +23,32 @@ public class ClosingTransaction extends CommonBase {
                if (ptr != 0) { bindings.ClosingTransaction_free(ptr); }
        }
 
+       /**
+        * Creates a copy of the ClosingTransaction
+        */
+       public ClosingTransaction clone() {
+               long ret = bindings.ClosingTransaction_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Checks if two ClosingTransactions contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.ClosingTransaction_hash(this.ptr);
+               return ret;
+       }
+
        /**
         * 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 >= 0 && ret < 1024) { return null; }
-               ClosingTransaction ret_hu_conv = new ClosingTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -44,8 +63,8 @@ public class ClosingTransaction extends CommonBase {
         */
        public TrustedClosingTransaction trust() {
                long ret = bindings.ClosingTransaction_trust(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               TrustedClosingTransaction ret_hu_conv = new TrustedClosingTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               TrustedClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TrustedClosingTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -60,7 +79,7 @@ public class ClosingTransaction extends CommonBase {
         */
        public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) {
                long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b014fdb55f70561a706400fbbd2e510bb997e32d..b50f886170e2817a2e3f782fac6269b4f02bff87 100644 (file)
@@ -98,7 +98,7 @@ public class ClosureReason extends CommonBase {
         */
        public ClosureReason clone() {
                long ret = bindings.ClosureReason_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -109,7 +109,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason counterparty_force_closed(java.lang.String peer_msg) {
                long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -120,7 +120,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason holder_force_closed() {
                long ret = bindings.ClosureReason_holder_force_closed();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -131,7 +131,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason cooperative_closure() {
                long ret = bindings.ClosureReason_cooperative_closure();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -142,7 +142,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason commitment_tx_confirmed() {
                long ret = bindings.ClosureReason_commitment_tx_confirmed();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -153,7 +153,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason processing_error(java.lang.String err) {
                long ret = bindings.ClosureReason_processing_error(err);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -164,7 +164,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason disconnected_peer() {
                long ret = bindings.ClosureReason_disconnected_peer();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -175,7 +175,7 @@ public class ClosureReason extends CommonBase {
         */
        public static ClosureReason outdated_channel_manager() {
                long ret = bindings.ClosureReason_outdated_channel_manager();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ClosureReason ret_hu_conv = ClosureReason.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index e7ac1a5891da8d62698a677f97585d3164b9ce52..85266a6e5943ce6c55edd71590ee8849edaa0d7f 100644 (file)
@@ -61,8 +61,8 @@ public class CommitmentSigned extends CommonBase {
         */
        public static CommitmentSigned of(byte[] channel_id_arg, byte[] signature_arg, byte[][] htlc_signatures_arg) {
                long ret = bindings.CommitmentSigned_new(channel_id_arg, signature_arg, htlc_signatures_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -72,8 +72,8 @@ public class CommitmentSigned extends CommonBase {
         */
        public CommitmentSigned clone() {
                long ret = bindings.CommitmentSigned_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -91,7 +91,7 @@ public class CommitmentSigned extends CommonBase {
         */
        public static Result_CommitmentSignedDecodeErrorZ read(byte[] ser) {
                long ret = bindings.CommitmentSigned_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index fafde095832f63db9ee8abf094d694805f528f59..276a69d05befe92ec30c0115d5a0861851d02f35 100644 (file)
@@ -29,8 +29,8 @@ public class CommitmentTransaction extends CommonBase {
         */
        public CommitmentTransaction clone() {
                long ret = bindings.CommitmentTransaction_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentTransaction ret_hu_conv = new CommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class CommitmentTransaction extends CommonBase {
         */
        public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) {
                long ret = bindings.CommitmentTransaction_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -95,8 +95,8 @@ public class CommitmentTransaction extends CommonBase {
         */
        public TrustedCommitmentTransaction trust() {
                long ret = bindings.CommitmentTransaction_trust(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               TrustedCommitmentTransaction ret_hu_conv = new TrustedCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               TrustedCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TrustedCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -111,7 +111,7 @@ public class CommitmentTransaction extends CommonBase {
         */
        public Result_TrustedCommitmentTransactionNoneZ verify(DirectedChannelTransactionParameters channel_parameters, ChannelPublicKeys broadcaster_keys, ChannelPublicKeys countersignatory_keys) {
                long ret = bindings.CommitmentTransaction_verify(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1, broadcaster_keys == null ? 0 : broadcaster_keys.ptr & ~1, countersignatory_keys == null ? 0 : countersignatory_keys.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(channel_parameters);
                this.ptrs_to.add(broadcaster_keys);
index 6b6e5f47aa56d78c620e2fe8938c12b16db1dbec..fe5bcf0c6378c1b8e19f61486c76afa01095ac12 100644 (file)
@@ -28,7 +28,7 @@ public class CommitmentUpdate extends CommonBase {
                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);
+                       UpdateAddHTLC ret_conv_15_hu_conv = null; if (ret_conv_15 < 0 || ret_conv_15 > 4096) { 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;
                }
@@ -50,7 +50,7 @@ public class CommitmentUpdate extends CommonBase {
                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);
+                       UpdateFulfillHTLC ret_conv_19_hu_conv = null; if (ret_conv_19 < 0 || ret_conv_19 > 4096) { 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;
                }
@@ -72,7 +72,7 @@ public class CommitmentUpdate extends CommonBase {
                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);
+                       UpdateFailHTLC ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { 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;
                }
@@ -94,7 +94,7 @@ public class CommitmentUpdate extends CommonBase {
                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);
+                       UpdateFailMalformedHTLC ret_conv_25_hu_conv = null; if (ret_conv_25 < 0 || ret_conv_25 > 4096) { 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;
                }
@@ -116,8 +116,8 @@ public class CommitmentUpdate extends CommonBase {
        @Nullable
        public UpdateFee get_update_fee() {
                long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFee ret_hu_conv = new UpdateFee(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -136,8 +136,8 @@ public class CommitmentUpdate extends CommonBase {
         */
        public CommitmentSigned get_commitment_signed() {
                long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -154,8 +154,8 @@ public class CommitmentUpdate extends CommonBase {
         */
        public static CommitmentUpdate of(UpdateAddHTLC[] update_add_htlcs_arg, UpdateFulfillHTLC[] update_fulfill_htlcs_arg, UpdateFailHTLC[] update_fail_htlcs_arg, UpdateFailMalformedHTLC[] update_fail_malformed_htlcs_arg, UpdateFee update_fee_arg, CommitmentSigned commitment_signed_arg) {
                long ret = bindings.CommitmentUpdate_new(update_add_htlcs_arg != null ? Arrays.stream(update_add_htlcs_arg).mapToLong(update_add_htlcs_arg_conv_15 -> update_add_htlcs_arg_conv_15 == null ? 0 : update_add_htlcs_arg_conv_15.ptr & ~1).toArray() : null, update_fulfill_htlcs_arg != null ? Arrays.stream(update_fulfill_htlcs_arg).mapToLong(update_fulfill_htlcs_arg_conv_19 -> update_fulfill_htlcs_arg_conv_19 == null ? 0 : update_fulfill_htlcs_arg_conv_19.ptr & ~1).toArray() : null, update_fail_htlcs_arg != null ? Arrays.stream(update_fail_htlcs_arg).mapToLong(update_fail_htlcs_arg_conv_16 -> update_fail_htlcs_arg_conv_16 == null ? 0 : update_fail_htlcs_arg_conv_16.ptr & ~1).toArray() : null, update_fail_malformed_htlcs_arg != null ? Arrays.stream(update_fail_malformed_htlcs_arg).mapToLong(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() : null, update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -165,8 +165,8 @@ public class CommitmentUpdate extends CommonBase {
         */
        public CommitmentUpdate clone() {
                long ret = bindings.CommitmentUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 9ee80fd74806aeb4e9bfb5e2ac3364fdb73ce9fd..604fb5acbb65f6f92051955d058b856d2cc61bba 100644 (file)
@@ -3,5 +3,5 @@ import java.util.LinkedList;
 class CommonBase {
        long ptr;
        LinkedList<Object> ptrs_to = new LinkedList();
-       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; }
+       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 4096; this.ptr = ptr; }
 }
index c322239a555ddca2b6101b2d656b89f0decfdfed..52ccf569e9a4e57a5e09f7dada374b20792150ee 100644 (file)
@@ -24,8 +24,8 @@ public class CounterpartyChannelTransactionParameters extends CommonBase {
         */
        public ChannelPublicKeys get_pubkeys() {
                long ret = bindings.CounterpartyChannelTransactionParameters_get_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class CounterpartyChannelTransactionParameters extends CommonBase {
         */
        public static CounterpartyChannelTransactionParameters of(ChannelPublicKeys pubkeys_arg, short selected_contest_delay_arg) {
                long ret = bindings.CounterpartyChannelTransactionParameters_new(pubkeys_arg == null ? 0 : pubkeys_arg.ptr & ~1, selected_contest_delay_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CounterpartyChannelTransactionParameters ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -68,8 +68,8 @@ public class CounterpartyChannelTransactionParameters extends CommonBase {
         */
        public CounterpartyChannelTransactionParameters clone() {
                long ret = bindings.CounterpartyChannelTransactionParameters_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CounterpartyChannelTransactionParameters ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -87,7 +87,7 @@ public class CounterpartyChannelTransactionParameters extends CommonBase {
         */
        public static Result_CounterpartyChannelTransactionParametersDecodeErrorZ read(byte[] ser) {
                long ret = bindings.CounterpartyChannelTransactionParameters_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CounterpartyChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_CounterpartyChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 96ca25a850c81349cec028cfaf4dbc338299b58d..7912abfe4306e0a906f9aebd58e61534184e7bfb 100644 (file)
@@ -73,8 +73,8 @@ public class CounterpartyForwardingInfo extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
-               CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyForwardingInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -84,8 +84,8 @@ public class CounterpartyForwardingInfo extends CommonBase {
         */
        public CounterpartyForwardingInfo clone() {
                long ret = bindings.CounterpartyForwardingInfo_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               CounterpartyForwardingInfo ret_hu_conv = new CounterpartyForwardingInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyForwardingInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 59fadd0962b78a50ed82b7958c1b212c40ba8ae1..81a32f934f480e4d163d3573f2965782ac79f52b 100644 (file)
@@ -73,7 +73,7 @@ public class CustomMessageHandler extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
index 889712a6188ee46c9defd2cdaf399e179553f75b..792dbb88377f580ecb3a7230e28444f0fe6f56ad 100644 (file)
@@ -53,7 +53,7 @@ public class CustomMessageReader extends CommonBase {
         */
        public Result_COption_TypeZDecodeErrorZ read(short message_type, byte[] buffer) {
                long ret = bindings.CustomMessageReader_read(this.ptr, message_type, buffer);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d8655be67f1d490569865359901091e1dfd367a8..70b3f3e16776fde4cebacaf82dab3759746b8f93 100644 (file)
@@ -59,8 +59,8 @@ public class DataLossProtect extends CommonBase {
         */
        public static DataLossProtect of(byte[] your_last_per_commitment_secret_arg, byte[] my_current_per_commitment_point_arg) {
                long ret = bindings.DataLossProtect_new(your_last_per_commitment_secret_arg, my_current_per_commitment_point_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DataLossProtect ret_hu_conv = new DataLossProtect(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DataLossProtect(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -70,8 +70,8 @@ public class DataLossProtect extends CommonBase {
         */
        public DataLossProtect clone() {
                long ret = bindings.DataLossProtect_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DataLossProtect ret_hu_conv = new DataLossProtect(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DataLossProtect ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DataLossProtect(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index dbf1fc88d164f483a48a38b544c1518a424a313f..5f7d8809b8b3b98763ef0c3614ea6b262d94d2c4 100644 (file)
@@ -24,8 +24,8 @@ public class DecodeError extends CommonBase {
         */
        public DecodeError clone() {
                long ret = bindings.DecodeError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DecodeError ret_hu_conv = new DecodeError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DecodeError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DecodeError(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/DefaultRouter.java b/src/main/java/org/ldk/structs/DefaultRouter.java
new file mode 100644 (file)
index 0000000..ae3fb4c
--- /dev/null
@@ -0,0 +1,47 @@
+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 [`Router`] implemented using [`find_route`].
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class DefaultRouter extends CommonBase {
+       DefaultRouter(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.DefaultRouter_free(ptr); }
+       }
+
+       /**
+        * Creates a new router using the given [`NetworkGraph`] and  [`Logger`].
+        */
+       public static DefaultRouter of(NetworkGraph network_graph, Logger logger) {
+               long ret = bindings.DefaultRouter_new(network_graph == null ? 0 : network_graph.ptr & ~1, logger == null ? 0 : logger.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DefaultRouter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DefaultRouter(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(network_graph);
+               ret_hu_conv.ptrs_to.add(logger);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Constructs a new Router which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is
+        */
+       public Router as_Router() {
+               long ret = bindings.DefaultRouter_as_Router(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Router ret_hu_conv = new Router(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+}
index 64dd10813094e5e021c66d82773a115ed3a31501..c0b84328a43f7c4cbd3b4133330e55fae42f377c 100644 (file)
@@ -25,8 +25,8 @@ public class DelayedPaymentOutputDescriptor extends CommonBase {
         */
        public OutPoint get_outpoint() {
                long ret = bindings.DelayedPaymentOutputDescriptor_get_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -133,8 +133,8 @@ public class DelayedPaymentOutputDescriptor extends CommonBase {
         */
        public static DelayedPaymentOutputDescriptor of(OutPoint outpoint_arg, byte[] per_commitment_point_arg, short to_self_delay_arg, TxOut output_arg, byte[] revocation_pubkey_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
                long ret = bindings.DelayedPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, per_commitment_point_arg, to_self_delay_arg, output_arg.ptr, revocation_pubkey_arg, channel_keys_id_arg, channel_value_satoshis_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DelayedPaymentOutputDescriptor ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -144,8 +144,8 @@ public class DelayedPaymentOutputDescriptor extends CommonBase {
         */
        public DelayedPaymentOutputDescriptor clone() {
                long ret = bindings.DelayedPaymentOutputDescriptor_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DelayedPaymentOutputDescriptor ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -163,7 +163,7 @@ public class DelayedPaymentOutputDescriptor extends CommonBase {
         */
        public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
                long ret = bindings.DelayedPaymentOutputDescriptor_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 7d224c7e6756384c97d34a6ba86db392ce87121e..707fff23af366e60af6894255701d16493308e15 100644 (file)
@@ -27,8 +27,8 @@ public class Description extends CommonBase {
         */
        public Description clone() {
                long ret = bindings.Description_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Description ret_hu_conv = new Description(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Description(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -60,7 +60,7 @@ public class Description extends CommonBase {
         */
        public static Result_DescriptionCreationErrorZ of(java.lang.String description) {
                long ret = bindings.Description_new(description);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2dad28cae85f3f4f63cf5493e56a9d586a3df7f1..36da85748535861dac1416bea206e39ad8a15d89 100644 (file)
@@ -28,8 +28,8 @@ public class DirectedChannelTransactionParameters extends CommonBase {
         */
        public ChannelPublicKeys broadcaster_pubkeys() {
                long ret = bindings.DirectedChannelTransactionParameters_broadcaster_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -39,8 +39,8 @@ public class DirectedChannelTransactionParameters extends CommonBase {
         */
        public ChannelPublicKeys countersignatory_pubkeys() {
                long ret = bindings.DirectedChannelTransactionParameters_countersignatory_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -70,8 +70,8 @@ public class DirectedChannelTransactionParameters extends CommonBase {
         */
        public OutPoint funding_outpoint() {
                long ret = bindings.DirectedChannelTransactionParameters_funding_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 2faa0727811d684d7468e4f8bd1c681545c74ec6..d90c4fc50b7ebf7c80ed4b5b7ace1681dc856f34 100644 (file)
@@ -87,7 +87,7 @@ public class DirectionalChannelInfo extends CommonBase {
         */
        public Option_u64Z get_htlc_maximum_msat() {
                long ret = bindings.DirectionalChannelInfo_get_htlc_maximum_msat(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -105,8 +105,8 @@ public class DirectionalChannelInfo extends CommonBase {
         */
        public RoutingFees get_fees() {
                long ret = bindings.DirectionalChannelInfo_get_fees(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RoutingFees ret_hu_conv = new RoutingFees(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -129,8 +129,8 @@ public class DirectionalChannelInfo extends CommonBase {
        @Nullable
        public ChannelUpdate get_last_update_message() {
                long ret = bindings.DirectionalChannelInfo_get_last_update_message(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -152,8 +152,8 @@ public class DirectionalChannelInfo extends CommonBase {
         */
        public static DirectionalChannelInfo of(int last_update_arg, boolean enabled_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg, RoutingFees fees_arg, ChannelUpdate last_update_message_arg) {
                long ret = bindings.DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg.ptr, fees_arg == null ? 0 : fees_arg.ptr & ~1, last_update_message_arg == null ? 0 : last_update_message_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -163,8 +163,8 @@ public class DirectionalChannelInfo extends CommonBase {
         */
        public DirectionalChannelInfo clone() {
                long ret = bindings.DirectionalChannelInfo_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -182,7 +182,7 @@ public class DirectionalChannelInfo extends CommonBase {
         */
        public static Result_DirectionalChannelInfoDecodeErrorZ read(byte[] ser) {
                long ret = bindings.DirectionalChannelInfo_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 12b8de2a51b591ffb47f25dbac5fc3397c817c1e..c13b9e519198f5066b68ddef4b855057f135b571 100644 (file)
@@ -45,7 +45,7 @@ public class ErrorAction extends CommonBase {
                private DisconnectPeer(long ptr, bindings.LDKErrorAction.DisconnectPeer obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
+                       ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -70,7 +70,7 @@ public class ErrorAction extends CommonBase {
                private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
+                       ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -80,7 +80,7 @@ public class ErrorAction extends CommonBase {
         */
        public ErrorAction clone() {
                long ret = bindings.ErrorAction_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -91,7 +91,7 @@ public class ErrorAction extends CommonBase {
         */
        public static ErrorAction disconnect_peer(ErrorMessage msg) {
                long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -102,7 +102,7 @@ public class ErrorAction extends CommonBase {
         */
        public static ErrorAction ignore_error() {
                long ret = bindings.ErrorAction_ignore_error();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -113,7 +113,7 @@ public class ErrorAction extends CommonBase {
         */
        public static ErrorAction ignore_and_log(org.ldk.enums.Level a) {
                long ret = bindings.ErrorAction_ignore_and_log(a);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -124,7 +124,7 @@ public class ErrorAction extends CommonBase {
         */
        public static ErrorAction send_error_message(ErrorMessage msg) {
                long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index a0ff44a494e869c171cd48e417bef1c0a96b1407..1fcb6d257f0d81b276e75f431f8381acd6c5fb2b 100644 (file)
@@ -60,8 +60,8 @@ public class ErrorMessage extends CommonBase {
         */
        public static ErrorMessage of(byte[] channel_id_arg, java.lang.String data_arg) {
                long ret = bindings.ErrorMessage_new(channel_id_arg, data_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ErrorMessage ret_hu_conv = new ErrorMessage(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -71,8 +71,8 @@ public class ErrorMessage extends CommonBase {
         */
        public ErrorMessage clone() {
                long ret = bindings.ErrorMessage_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ErrorMessage ret_hu_conv = new ErrorMessage(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -90,7 +90,7 @@ public class ErrorMessage extends CommonBase {
         */
        public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ErrorMessage_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 38be35bd3de2b4e2671c233128e3f9cda24ad8ab..265bb62126c3919d7876407e7744fd7b9b93690d 100644 (file)
@@ -25,8 +25,8 @@ public class ErroringMessageHandler extends CommonBase {
         */
        public static ErroringMessageHandler of() {
                long ret = bindings.ErroringMessageHandler_new();
-               if (ret >= 0 && ret < 1024) { return null; }
-               ErroringMessageHandler ret_hu_conv = new ErroringMessageHandler(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ErroringMessageHandler ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErroringMessageHandler(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -37,7 +37,7 @@ public class ErroringMessageHandler extends CommonBase {
         */
        public MessageSendEventsProvider as_MessageSendEventsProvider() {
                long ret = bindings.ErroringMessageHandler_as_MessageSendEventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -49,7 +49,7 @@ public class ErroringMessageHandler extends CommonBase {
         */
        public ChannelMessageHandler as_ChannelMessageHandler() {
                long ret = bindings.ErroringMessageHandler_as_ChannelMessageHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 8d0a036484dc7c0a187760f09d448026a81ee2d5..d3f85fed9e8df907eea826de13b43fd18d0268ef 100644 (file)
@@ -108,6 +108,16 @@ public class Event extends CommonBase {
                }
        }
        public final static class PaymentSent extends Event {
+               /**
+                * The id returned by [`ChannelManager::send_payment`] and used with
+                * [`ChannelManager::retry_payment`].
+                * 
+                * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+                * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final byte[] payment_id;
                /**
                 * The preimage to the hash given to ChannelManager::send_payment.
                 * Note that this serves as a payment receipt, if you wish to have such a thing, you must
@@ -120,13 +130,40 @@ public class Event extends CommonBase {
                 * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
                */
                public final byte[] payment_hash;
+               /**
+                * The total fee which was spent at intermediate hops in this payment, across all paths.
+                * 
+                * Note that, like [`Route::get_total_fees`] this does *not* include any potential
+                * overpayment to the recipient node.
+                * 
+                * If the recipient or an intermediate node misbehaves and gives us free money, this may
+                * overstate the amount paid, though this is unlikely.
+                * 
+                * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
+               */
+               public final Option_u64Z fee_paid_msat;
                private PaymentSent(long ptr, bindings.LDKEvent.PaymentSent obj) {
                        super(null, ptr);
+                       this.payment_id = obj.payment_id;
                        this.payment_preimage = obj.payment_preimage;
                        this.payment_hash = obj.payment_hash;
+                       long fee_paid_msat = obj.fee_paid_msat;
+                       Option_u64Z fee_paid_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_paid_msat);
+                       fee_paid_msat_hu_conv.ptrs_to.add(this);
+                       this.fee_paid_msat = fee_paid_msat_hu_conv;
                }
        }
        public final static class PaymentPathFailed extends Event {
+               /**
+                * The id returned by [`ChannelManager::send_payment`] and used with
+                * [`ChannelManager::retry_payment`].
+                * 
+                * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+                * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final byte[] payment_id;
                /**
                 * The hash which was given to ChannelManager::send_payment.
                */
@@ -165,8 +202,20 @@ public class Event extends CommonBase {
                 * retried. May be `None` for older [`Event`] serializations.
                */
                public final Option_u64Z short_channel_id;
+               /**
+                * Parameters needed to compute a new [`Route`] when retrying the failed payment path.
+                * 
+                * See [`find_route`] for details.
+                * 
+                * [`Route`]: crate::routing::router::Route
+                * [`find_route`]: crate::routing::router::find_route
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final RouteParameters retry;
                private PaymentPathFailed(long ptr, bindings.LDKEvent.PaymentPathFailed obj) {
                        super(null, ptr);
+                       this.payment_id = obj.payment_id;
                        this.payment_hash = obj.payment_hash;
                        this.rejected_by_dest = obj.rejected_by_dest;
                        long network_update = obj.network_update;
@@ -178,7 +227,7 @@ public class Event extends CommonBase {
                        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);
+                               RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { 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;
                        }
@@ -187,6 +236,10 @@ public class Event extends CommonBase {
                        Option_u64Z short_channel_id_hu_conv = Option_u64Z.constr_from_ptr(short_channel_id);
                        short_channel_id_hu_conv.ptrs_to.add(this);
                        this.short_channel_id = short_channel_id_hu_conv;
+                       long retry = obj.retry;
+                       RouteParameters retry_hu_conv = null; if (retry < 0 || retry > 4096) { retry_hu_conv = new RouteParameters(null, retry); }
+                       retry_hu_conv.ptrs_to.add(this);
+                       this.retry = retry_hu_conv;
                }
        }
        public final static class PendingHTLCsForwardable extends Event {
@@ -299,7 +352,7 @@ public class Event extends CommonBase {
         */
        public Event clone() {
                long ret = bindings.Event_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -310,7 +363,7 @@ public class Event extends CommonBase {
         */
        public static Event funding_generation_ready(byte[] temporary_channel_id, long channel_value_satoshis, byte[] output_script, long user_channel_id) {
                long ret = bindings.Event_funding_generation_ready(temporary_channel_id, channel_value_satoshis, output_script, user_channel_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -321,7 +374,7 @@ public class Event extends CommonBase {
         */
        public static Event payment_received(byte[] payment_hash, long amt, PaymentPurpose purpose) {
                long ret = bindings.Event_payment_received(payment_hash, amt, purpose.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -330,9 +383,9 @@ public class Event extends CommonBase {
        /**
         * Utility method to constructs a new PaymentSent-variant Event
         */
-       public static Event payment_sent(byte[] payment_preimage, byte[] payment_hash) {
-               long ret = bindings.Event_payment_sent(payment_preimage, payment_hash);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static Event payment_sent(byte[] payment_id, byte[] payment_preimage, byte[] payment_hash, Option_u64Z fee_paid_msat) {
+               long ret = bindings.Event_payment_sent(payment_id, payment_preimage, payment_hash, fee_paid_msat.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -341,9 +394,9 @@ public class Event extends CommonBase {
        /**
         * Utility method to constructs a new PaymentPathFailed-variant Event
         */
-       public static Event payment_path_failed(byte[] payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id) {
-               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, short_channel_id.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static Event payment_path_failed(byte[] payment_id, byte[] payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id, RouteParameters retry) {
+               long ret = bindings.Event_payment_path_failed(payment_id, 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, short_channel_id.ptr, retry == null ? 0 : retry.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -354,7 +407,7 @@ public class Event extends CommonBase {
         */
        public static Event pending_htlcs_forwardable(long time_forwardable) {
                long ret = bindings.Event_pending_htlcs_forwardable(time_forwardable);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -365,7 +418,7 @@ public class Event extends CommonBase {
         */
        public static Event spendable_outputs(SpendableOutputDescriptor[] outputs) {
                long ret = bindings.Event_spendable_outputs(outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_27 -> outputs_conv_27.ptr).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -376,7 +429,7 @@ public class Event extends CommonBase {
         */
        public static Event payment_forwarded(Option_u64Z fee_earned_msat, boolean claim_from_onchain_tx) {
                long ret = bindings.Event_payment_forwarded(fee_earned_msat.ptr, claim_from_onchain_tx);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -387,7 +440,7 @@ public class Event extends CommonBase {
         */
        public static Event channel_closed(byte[] channel_id, long user_channel_id, ClosureReason reason) {
                long ret = bindings.Event_channel_closed(channel_id, user_channel_id, reason.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -398,7 +451,7 @@ public class Event extends CommonBase {
         */
        public static Event discard_funding(byte[] channel_id, byte[] transaction) {
                long ret = bindings.Event_discard_funding(channel_id, transaction);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 972befdaca3c833dc8d144772a2405edfe808dcc..60c7a2e0c75b1a17812aaf4ded54ba0bb4285f1d 100644 (file)
@@ -30,8 +30,8 @@ public class ExpiryTime extends CommonBase {
         */
        public ExpiryTime clone() {
                long ret = bindings.ExpiryTime_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ExpiryTime ret_hu_conv = new ExpiryTime(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class ExpiryTime extends CommonBase {
         */
        public static Result_ExpiryTimeCreationErrorZ from_seconds(long seconds) {
                long ret = bindings.ExpiryTime_from_seconds(seconds);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -74,7 +74,7 @@ public class ExpiryTime extends CommonBase {
         */
        public static Result_ExpiryTimeCreationErrorZ from_duration(long duration) {
                long ret = bindings.ExpiryTime_from_duration(duration);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5ec806edcf4e71579da83d01e293d42425a66f60..3e687e7cf17d912704d3a02ec783016639beead1 100644 (file)
@@ -62,7 +62,7 @@ public class Fallback extends CommonBase {
         */
        public Fallback clone() {
                long ret = bindings.Fallback_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -73,7 +73,7 @@ public class Fallback extends CommonBase {
         */
        public static Fallback seg_wit_program(UInt5 version, byte[] program) {
                long ret = bindings.Fallback_seg_wit_program(version.getVal(), program);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -84,7 +84,7 @@ public class Fallback extends CommonBase {
         */
        public static Fallback pub_key_hash(byte[] a) {
                long ret = bindings.Fallback_pub_key_hash(a);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -95,7 +95,7 @@ public class Fallback extends CommonBase {
         */
        public static Fallback script_hash(byte[] a) {
                long ret = bindings.Fallback_script_hash(a);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 8ef595f1d5df8c27f785c47101bdea606fa7cf79..a3d56328bff797b37e15de7ff65a6d8a62e5fd54 100644 (file)
@@ -36,8 +36,8 @@ public class FilesystemPersister extends CommonBase {
         */
        public static FilesystemPersister of(java.lang.String path_to_channel_data) {
                long ret = bindings.FilesystemPersister_new(path_to_channel_data);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FilesystemPersister ret_hu_conv = new FilesystemPersister(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FilesystemPersister ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FilesystemPersister(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -55,7 +55,7 @@ public class FilesystemPersister extends CommonBase {
         */
        public Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ read_channelmonitors(KeysInterface keys_manager) {
                long ret = bindings.FilesystemPersister_read_channelmonitors(this.ptr, keys_manager == null ? 0 : keys_manager.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(keys_manager);
                return ret_hu_conv;
@@ -67,7 +67,7 @@ public class FilesystemPersister extends CommonBase {
         */
        public Persist as_Persist() {
                long ret = bindings.FilesystemPersister_as_Persist(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Persist ret_hu_conv = new Persist(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 1225210dd64eda8b85887a0b7a51750cb7445ecc..f93f321da09b0bb601775c4939e90a16ada9fa56 100644 (file)
@@ -69,7 +69,7 @@ public class Filter extends CommonBase {
                                arg.register_tx(txid, script_pubkey);
                        }
                        @Override public long register_output(long output) {
-                               WatchedOutput output_hu_conv = new WatchedOutput(null, output);
+                               WatchedOutput output_hu_conv = null; if (output < 0 || output > 4096) { output_hu_conv = new WatchedOutput(null, output); }
                                output_hu_conv.ptrs_to.add(this);
                                Option_C2Tuple_usizeTransactionZZ ret = arg.register_output(output_hu_conv);
                                long result = ret.ptr;
@@ -99,7 +99,7 @@ public class Filter extends CommonBase {
         */
        public Option_C2Tuple_usizeTransactionZZ register_output(WatchedOutput output) {
                long ret = bindings.Filter_register_output(this.ptr, output == null ? 0 : output.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_C2Tuple_usizeTransactionZZ ret_hu_conv = Option_C2Tuple_usizeTransactionZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index dcf21c2f33005463007564fcb7ef879442e57824..0585d27a0d55c24907c2383a8bae8de2d4a61756 100644 (file)
@@ -84,8 +84,8 @@ public class FundingCreated extends CommonBase {
         */
        public static FundingCreated of(byte[] temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) {
                long ret = bindings.FundingCreated_new(temporary_channel_id_arg, funding_txid_arg, funding_output_index_arg, signature_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingCreated ret_hu_conv = new FundingCreated(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingCreated(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -95,8 +95,8 @@ public class FundingCreated extends CommonBase {
         */
        public FundingCreated clone() {
                long ret = bindings.FundingCreated_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingCreated ret_hu_conv = new FundingCreated(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingCreated(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -114,7 +114,7 @@ public class FundingCreated extends CommonBase {
         */
        public static Result_FundingCreatedDecodeErrorZ read(byte[] ser) {
                long ret = bindings.FundingCreated_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 1f50eb3aeda89f2219ee7397f81a720a5512ff80..b5f9b1e26147e121da99cd4e19c67dbb8f340235 100644 (file)
@@ -54,8 +54,8 @@ public class FundingLocked extends CommonBase {
         */
        public static FundingLocked of(byte[] channel_id_arg, byte[] next_per_commitment_point_arg) {
                long ret = bindings.FundingLocked_new(channel_id_arg, next_per_commitment_point_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingLocked ret_hu_conv = new FundingLocked(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingLocked ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingLocked(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -65,8 +65,8 @@ public class FundingLocked extends CommonBase {
         */
        public FundingLocked clone() {
                long ret = bindings.FundingLocked_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingLocked ret_hu_conv = new FundingLocked(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingLocked ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingLocked(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,7 +84,7 @@ public class FundingLocked extends CommonBase {
         */
        public static Result_FundingLockedDecodeErrorZ read(byte[] ser) {
                long ret = bindings.FundingLocked_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingLockedDecodeErrorZ ret_hu_conv = Result_FundingLockedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 198c8886b2a9b9743a0031dc0e07a0732a2a7748..b56363bc3e780b8da995860eca484cd6830025fc 100644 (file)
@@ -54,8 +54,8 @@ public class FundingSigned extends CommonBase {
         */
        public static FundingSigned of(byte[] channel_id_arg, byte[] signature_arg) {
                long ret = bindings.FundingSigned_new(channel_id_arg, signature_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingSigned ret_hu_conv = new FundingSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -65,8 +65,8 @@ public class FundingSigned extends CommonBase {
         */
        public FundingSigned clone() {
                long ret = bindings.FundingSigned_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               FundingSigned ret_hu_conv = new FundingSigned(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingSigned(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,7 +84,7 @@ public class FundingSigned extends CommonBase {
         */
        public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
                long ret = bindings.FundingSigned_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a1dc07a763a32a531ab9ae6dbcf72bbb30ab1af7..2693985bcfab6913ccad310676a52249624f77ff 100644 (file)
@@ -71,8 +71,8 @@ public class GossipTimestampFilter extends CommonBase {
         */
        public static GossipTimestampFilter of(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) {
                long ret = bindings.GossipTimestampFilter_new(chain_hash_arg, first_timestamp_arg, timestamp_range_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               GossipTimestampFilter ret_hu_conv = new GossipTimestampFilter(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new GossipTimestampFilter(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -82,8 +82,8 @@ public class GossipTimestampFilter extends CommonBase {
         */
        public GossipTimestampFilter clone() {
                long ret = bindings.GossipTimestampFilter_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               GossipTimestampFilter ret_hu_conv = new GossipTimestampFilter(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new GossipTimestampFilter(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -101,7 +101,7 @@ public class GossipTimestampFilter extends CommonBase {
         */
        public static Result_GossipTimestampFilterDecodeErrorZ read(byte[] ser) {
                long ret = bindings.GossipTimestampFilter_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 92cf8fdde172a3bdd15b6995570828875f355bbf..55f2cb22660b110e45e1046c135075223d56e865 100644 (file)
@@ -94,7 +94,7 @@ public class HTLCOutputInCommitment extends CommonBase {
         */
        public Option_u32Z get_transaction_output_index() {
                long ret = bindings.HTLCOutputInCommitment_get_transaction_output_index(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -114,8 +114,8 @@ public class HTLCOutputInCommitment extends CommonBase {
         */
        public static HTLCOutputInCommitment of(boolean offered_arg, long amount_msat_arg, int cltv_expiry_arg, byte[] payment_hash_arg, Option_u32Z transaction_output_index_arg) {
                long ret = bindings.HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg, transaction_output_index_arg.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               HTLCOutputInCommitment ret_hu_conv = new HTLCOutputInCommitment(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -125,8 +125,8 @@ public class HTLCOutputInCommitment extends CommonBase {
         */
        public HTLCOutputInCommitment clone() {
                long ret = bindings.HTLCOutputInCommitment_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               HTLCOutputInCommitment ret_hu_conv = new HTLCOutputInCommitment(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCOutputInCommitment(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -144,7 +144,7 @@ public class HTLCOutputInCommitment extends CommonBase {
         */
        public static Result_HTLCOutputInCommitmentDecodeErrorZ read(byte[] ser) {
                long ret = bindings.HTLCOutputInCommitment_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 105a166a5b482ce0977fb26fc957456a295bd3cb..8831420b36588489cf6b8007a472b3447e6e2feb 100644 (file)
@@ -26,8 +26,8 @@ public class HTLCUpdate extends CommonBase {
         */
        public HTLCUpdate clone() {
                long ret = bindings.HTLCUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               HTLCUpdate ret_hu_conv = new HTLCUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               HTLCUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HTLCUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -45,7 +45,7 @@ public class HTLCUpdate extends CommonBase {
         */
        public static Result_HTLCUpdateDecodeErrorZ read(byte[] ser) {
                long ret = bindings.HTLCUpdate_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCUpdateDecodeErrorZ ret_hu_conv = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9cbd0d70c624b945de011527271badd326fdeef4..5e32620174b516c9624be7017406777d1e03ed02 100644 (file)
@@ -48,8 +48,8 @@ public class HolderCommitmentTransaction extends CommonBase {
         */
        public HolderCommitmentTransaction clone() {
                long ret = bindings.HolderCommitmentTransaction_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HolderCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class HolderCommitmentTransaction extends CommonBase {
         */
        public static Result_HolderCommitmentTransactionDecodeErrorZ read(byte[] ser) {
                long ret = bindings.HolderCommitmentTransaction_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -78,8 +78,8 @@ public class HolderCommitmentTransaction extends CommonBase {
         */
        public static HolderCommitmentTransaction of(CommitmentTransaction commitment_tx, byte[] counterparty_sig, byte[][] counterparty_htlc_sigs, byte[] holder_funding_key, byte[] counterparty_funding_key) {
                long ret = bindings.HolderCommitmentTransaction_new(commitment_tx == null ? 0 : commitment_tx.ptr & ~1, counterparty_sig, counterparty_htlc_sigs, holder_funding_key, counterparty_funding_key);
-               if (ret >= 0 && ret < 1024) { return null; }
-               HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new HolderCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
index 5a9920dcac3f7d02a348482e27009d5a6071c08a..a45a45dbe0af2330cb7772e2f85405c680c72820 100644 (file)
@@ -25,8 +25,8 @@ public class IgnoringMessageHandler extends CommonBase {
         */
        public static IgnoringMessageHandler of() {
                long ret = bindings.IgnoringMessageHandler_new();
-               if (ret >= 0 && ret < 1024) { return null; }
-               IgnoringMessageHandler ret_hu_conv = new IgnoringMessageHandler(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               IgnoringMessageHandler ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new IgnoringMessageHandler(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -37,7 +37,7 @@ public class IgnoringMessageHandler extends CommonBase {
         */
        public MessageSendEventsProvider as_MessageSendEventsProvider() {
                long ret = bindings.IgnoringMessageHandler_as_MessageSendEventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -49,7 +49,7 @@ public class IgnoringMessageHandler extends CommonBase {
         */
        public RoutingMessageHandler as_RoutingMessageHandler() {
                long ret = bindings.IgnoringMessageHandler_as_RoutingMessageHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -61,7 +61,7 @@ public class IgnoringMessageHandler extends CommonBase {
         */
        public CustomMessageReader as_CustomMessageReader() {
                long ret = bindings.IgnoringMessageHandler_as_CustomMessageReader(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                CustomMessageReader ret_hu_conv = new CustomMessageReader(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -73,7 +73,7 @@ public class IgnoringMessageHandler extends CommonBase {
         */
        public CustomMessageHandler as_CustomMessageHandler() {
                long ret = bindings.IgnoringMessageHandler_as_CustomMessageHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                CustomMessageHandler ret_hu_conv = new CustomMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 832db81584bae28ca49f8d9e4dc55e782e83bb25..cdfc34ada54b416630b8c787d88bf52648fce278 100644 (file)
@@ -117,8 +117,8 @@ public class InMemorySigner extends CommonBase {
         */
        public InMemorySigner clone() {
                long ret = bindings.InMemorySigner_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InMemorySigner ret_hu_conv = new InMemorySigner(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -128,8 +128,8 @@ public class InMemorySigner extends CommonBase {
         */
        public static InMemorySigner of(byte[] funding_key, byte[] revocation_base_key, byte[] payment_key, byte[] delayed_payment_base_key, byte[] htlc_base_key, byte[] commitment_seed, long channel_value_satoshis, byte[] channel_keys_id) {
                long ret = bindings.InMemorySigner_new(funding_key, revocation_base_key, payment_key, delayed_payment_base_key, htlc_base_key, commitment_seed, channel_value_satoshis, channel_keys_id);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InMemorySigner ret_hu_conv = new InMemorySigner(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -140,8 +140,8 @@ public class InMemorySigner extends CommonBase {
         */
        public ChannelPublicKeys counterparty_pubkeys() {
                long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -183,8 +183,8 @@ public class InMemorySigner extends CommonBase {
         */
        public OutPoint funding_outpoint() {
                long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -197,8 +197,8 @@ public class InMemorySigner extends CommonBase {
         */
        public ChannelTransactionParameters get_channel_parameters() {
                long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -212,7 +212,7 @@ public class InMemorySigner extends CommonBase {
         */
        public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, StaticPaymentOutputDescriptor descriptor) {
                long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(descriptor);
                return ret_hu_conv;
@@ -228,7 +228,7 @@ public class InMemorySigner extends CommonBase {
         */
        public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, DelayedPaymentOutputDescriptor descriptor) {
                long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(descriptor);
                return ret_hu_conv;
@@ -240,7 +240,7 @@ public class InMemorySigner extends CommonBase {
         */
        public BaseSign as_BaseSign() {
                long ret = bindings.InMemorySigner_as_BaseSign(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                BaseSign ret_hu_conv = new BaseSign(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -252,7 +252,7 @@ public class InMemorySigner extends CommonBase {
         */
        public Sign as_Sign() {
                long ret = bindings.InMemorySigner_as_Sign(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Sign ret_hu_conv = new Sign(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -271,7 +271,7 @@ public class InMemorySigner extends CommonBase {
         */
        public static Result_InMemorySignerDecodeErrorZ read(byte[] ser) {
                long ret = bindings.InMemorySigner_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index cb6f8727677ea445408b0dfb583e9e7dfb2c8435..69f97fa9948ec2d194ac31f40d44b72cdf04f71c 100644 (file)
@@ -24,8 +24,8 @@ public class Init extends CommonBase {
         */
        public InitFeatures get_features() {
                long ret = bindings.Init_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InitFeatures ret_hu_conv = new InitFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -42,8 +42,8 @@ public class Init extends CommonBase {
         */
        public static Init of(InitFeatures features_arg) {
                long ret = bindings.Init_new(features_arg == null ? 0 : features_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Init ret_hu_conv = new Init(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -53,8 +53,8 @@ public class Init extends CommonBase {
         */
        public Init clone() {
                long ret = bindings.Init_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Init ret_hu_conv = new Init(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Init ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Init(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -72,7 +72,7 @@ public class Init extends CommonBase {
         */
        public static Result_InitDecodeErrorZ read(byte[] ser) {
                long ret = bindings.Init_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 6e68f95ac017509e378492d33d3739fb88e0f20e..d8ead50a65e8de3307d3f85ad95d45b071b86123 100644 (file)
@@ -35,8 +35,8 @@ public class InitFeatures extends CommonBase {
         */
        public InitFeatures clone() {
                long ret = bindings.InitFeatures_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InitFeatures ret_hu_conv = new InitFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -46,8 +46,8 @@ public class InitFeatures extends CommonBase {
         */
        public static InitFeatures empty() {
                long ret = bindings.InitFeatures_empty();
-               if (ret >= 0 && ret < 1024) { return null; }
-               InitFeatures ret_hu_conv = new InitFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class InitFeatures extends CommonBase {
         */
        public static InitFeatures known() {
                long ret = bindings.InitFeatures_known();
-               if (ret >= 0 && ret < 1024) { return null; }
-               InitFeatures ret_hu_conv = new InitFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -93,7 +93,7 @@ public class InitFeatures extends CommonBase {
         */
        public static Result_InitFeaturesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.InitFeatures_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitFeaturesDecodeErrorZ ret_hu_conv = Result_InitFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 16fe91f19db4fa8a41f5564c2e3ca4ff9d5ad8d1..abea7e8098dfb38f72b3819b4633bcf6c4d5c4e6 100644 (file)
@@ -43,10 +43,21 @@ public class InvalidShutdownScript extends CommonBase {
         */
        public static InvalidShutdownScript of(byte[] script_arg) {
                long ret = bindings.InvalidShutdownScript_new(script_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvalidShutdownScript ret_hu_conv = new InvalidShutdownScript(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvalidShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvalidShutdownScript(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
 
+       /**
+        * Creates a copy of the InvalidShutdownScript
+        */
+       public InvalidShutdownScript clone() {
+               long ret = bindings.InvalidShutdownScript_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvalidShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvalidShutdownScript(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index ca8e9c85d7230adde7d10111e5e6e08260974479..968b221ac58c07301c19a824b9ee649ad8027ed3 100644 (file)
@@ -40,8 +40,8 @@ public class Invoice extends CommonBase {
         */
        public Invoice clone() {
                long ret = bindings.Invoice_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Invoice ret_hu_conv = new Invoice(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Invoice(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -51,8 +51,8 @@ public class Invoice extends CommonBase {
         */
        public SignedRawInvoice into_signed_raw() {
                long ret = bindings.Invoice_into_signed_raw(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               SignedRawInvoice ret_hu_conv = new SignedRawInvoice(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new SignedRawInvoice(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                ;
                return ret_hu_conv;
@@ -63,7 +63,7 @@ public class Invoice extends CommonBase {
         */
        public Result_NoneSemanticErrorZ check_signature() {
                long ret = bindings.Invoice_check_signature(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneSemanticErrorZ ret_hu_conv = Result_NoneSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -92,7 +92,7 @@ public class Invoice extends CommonBase {
         */
        public static Result_InvoiceSemanticErrorZ from_signed(SignedRawInvoice signed_invoice) {
                long ret = bindings.Invoice_from_signed(signed_invoice == null ? 0 : signed_invoice.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSemanticErrorZ ret_hu_conv = Result_InvoiceSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -140,8 +140,8 @@ public class Invoice extends CommonBase {
        @Nullable
        public InvoiceFeatures features() {
                long ret = bindings.Invoice_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceFeatures ret_hu_conv = new InvoiceFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -162,6 +162,14 @@ public class Invoice extends CommonBase {
                return ret;
        }
 
+       /**
+        * Returns whether the invoice has expired.
+        */
+       public boolean is_expired() {
+               boolean ret = bindings.Invoice_is_expired(this.ptr);
+               return ret;
+       }
+
        /**
         * Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise
         * [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
@@ -179,7 +187,7 @@ public class Invoice extends CommonBase {
                PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret.length];
                for (int o = 0; o < ret.length; o++) {
                        long ret_conv_14 = ret[o];
-                       PrivateRoute ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14);
+                       PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14); }
                        ret_conv_14_hu_conv.ptrs_to.add(this);
                        ret_conv_14_arr[o] = ret_conv_14_hu_conv;
                }
@@ -194,7 +202,7 @@ public class Invoice extends CommonBase {
                RouteHint[] ret_conv_11_arr = new RouteHint[ret.length];
                for (int l = 0; l < ret.length; l++) {
                        long ret_conv_11 = ret[l];
-                       RouteHint ret_conv_11_hu_conv = new RouteHint(null, ret_conv_11);
+                       RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new RouteHint(null, ret_conv_11); }
                        ret_conv_11_hu_conv.ptrs_to.add(this);
                        ret_conv_11_arr[l] = ret_conv_11_hu_conv;
                }
@@ -210,11 +218,11 @@ public class Invoice extends CommonBase {
        }
 
        /**
-        * Returns the amount if specified in the invoice as pico <currency>.
+        * Returns the amount if specified in the invoice as millisatoshis.
         */
-       public Option_u64Z amount_pico_btc() {
-               long ret = bindings.Invoice_amount_pico_btc(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public Option_u64Z amount_milli_satoshis() {
+               long ret = bindings.Invoice_amount_milli_satoshis(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -225,7 +233,7 @@ public class Invoice extends CommonBase {
         */
        public static Result_InvoiceNoneZ from_str(java.lang.String s) {
                long ret = bindings.Invoice_from_str(s);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceNoneZ ret_hu_conv = Result_InvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 3ae93479bbf472d71265b4d38972e286a90cbf81..ccbf4f526897f51a8f19e1c6ae326b7b3517bf07 100644 (file)
@@ -35,8 +35,8 @@ public class InvoiceFeatures extends CommonBase {
         */
        public InvoiceFeatures clone() {
                long ret = bindings.InvoiceFeatures_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceFeatures ret_hu_conv = new InvoiceFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -46,8 +46,8 @@ public class InvoiceFeatures extends CommonBase {
         */
        public static InvoiceFeatures empty() {
                long ret = bindings.InvoiceFeatures_empty();
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceFeatures ret_hu_conv = new InvoiceFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class InvoiceFeatures extends CommonBase {
         */
        public static InvoiceFeatures known() {
                long ret = bindings.InvoiceFeatures_known();
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceFeatures ret_hu_conv = new InvoiceFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -93,7 +93,7 @@ public class InvoiceFeatures extends CommonBase {
         */
        public static Result_InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.InvoiceFeatures_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/InvoicePayer.java b/src/main/java/org/ldk/structs/InvoicePayer.java
new file mode 100644 (file)
index 0000000..4c6d63f
--- /dev/null
@@ -0,0 +1,94 @@
+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 utility for paying [`Invoice]`s.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class InvoicePayer extends CommonBase {
+       InvoicePayer(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.InvoicePayer_free(ptr); }
+       }
+
+       /**
+        * Creates an invoice payer that retries failed payment paths.
+        * 
+        * Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once
+        * `retry_attempts` has been exceeded for a given [`Invoice`].
+        */
+       public static InvoicePayer of(Payer payer, Router router, LockableScore scorer, Logger logger, EventHandler event_handler, RetryAttempts retry_attempts) {
+               long ret = bindings.InvoicePayer_new(payer == null ? 0 : payer.ptr, router == null ? 0 : router.ptr, scorer == null ? 0 : scorer.ptr & ~1, logger == null ? 0 : logger.ptr, event_handler == null ? 0 : event_handler.ptr, retry_attempts == null ? 0 : retry_attempts.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoicePayer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoicePayer(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(payer);
+               ret_hu_conv.ptrs_to.add(router);
+               ret_hu_conv.ptrs_to.add(scorer);
+               ret_hu_conv.ptrs_to.add(logger);
+               ret_hu_conv.ptrs_to.add(event_handler);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Pays the given [`Invoice`], caching it for later use in case a retry is needed.
+        * 
+        * You should ensure that the `invoice.payment_hash()` is unique and the same payment_hash has
+        * never been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so
+        * for you.
+        */
+       public Result_PaymentIdPaymentErrorZ pay_invoice(Invoice invoice) {
+               long ret = bindings.InvoicePayer_pay_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(invoice);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Pays the given zero-value [`Invoice`] using the given amount, caching it for later use in
+        * case a retry is needed.
+        * 
+        * You should ensure that the `invoice.payment_hash()` is unique and the same payment_hash has
+        * never been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so
+        * for you.
+        */
+       public Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(Invoice invoice, long amount_msats) {
+               long ret = bindings.InvoicePayer_pay_zero_value_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1, amount_msats);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(invoice);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Removes the payment cached by the given payment hash.
+        * 
+        * Should be called once a payment has failed or succeeded if not using [`InvoicePayer`] as an
+        * [`EventHandler`]. Otherwise, calling this method is unnecessary.
+        */
+       public void remove_cached_payment(byte[] payment_hash) {
+               bindings.InvoicePayer_remove_cached_payment(this.ptr, payment_hash);
+       }
+
+       /**
+        * 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 EventHandler as_EventHandler() {
+               long ret = bindings.InvoicePayer_as_EventHandler(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               EventHandler ret_hu_conv = new EventHandler(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+}
index a08e487d6c6cc9a36022940d5e9e406286385e72..8ff00fc63149835993d9c2c364abde30915740b6 100644 (file)
@@ -24,8 +24,8 @@ public class InvoiceSignature extends CommonBase {
         */
        public InvoiceSignature clone() {
                long ret = bindings.InvoiceSignature_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceSignature ret_hu_conv = new InvoiceSignature(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceSignature(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index d74e35b69b612cd690c13f03a2b57f0ef0a8a2a4..ea88ec2c61a4377ba40ade74dfca2c7f54fd5058 100644 (file)
@@ -145,8 +145,8 @@ public class KeysInterface extends CommonBase {
         */
        public ShutdownScript get_shutdown_scriptpubkey() {
                long ret = bindings.KeysInterface_get_shutdown_scriptpubkey(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ShutdownScript ret_hu_conv = new ShutdownScript(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -159,7 +159,7 @@ public class KeysInterface extends CommonBase {
         */
        public Sign get_channel_signer(boolean inbound, long channel_value_satoshis) {
                long ret = bindings.KeysInterface_get_channel_signer(this.ptr, inbound, channel_value_satoshis);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Sign ret_hu_conv = new Sign(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -187,7 +187,7 @@ public class KeysInterface extends CommonBase {
         */
        public Result_SignDecodeErrorZ read_chan_signer(byte[] reader) {
                long ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -200,7 +200,7 @@ public class KeysInterface extends CommonBase {
         */
        public Result_RecoverableSignatureNoneZ sign_invoice(byte[] invoice_preimage) {
                long ret = bindings.KeysInterface_sign_invoice(this.ptr, invoice_preimage);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 1b6e65fdff2f65dc5976bcd0d3b6e19b801821b8..04563c4273f94c58c8be11c3a1e945d3af6d779b 100644 (file)
@@ -48,8 +48,8 @@ public class KeysManager extends CommonBase {
         */
        public static KeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos) {
                long ret = bindings.KeysManager_new(seed, starting_time_secs, starting_time_nanos);
-               if (ret >= 0 && ret < 1024) { return null; }
-               KeysManager ret_hu_conv = new KeysManager(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               KeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new KeysManager(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -63,8 +63,8 @@ public class KeysManager extends CommonBase {
         */
        public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] params) {
                long ret = bindings.KeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, params);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InMemorySigner ret_hu_conv = new InMemorySigner(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,7 +84,7 @@ public class KeysManager extends CommonBase {
         */
        public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight) {
                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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -95,7 +95,7 @@ public class KeysManager extends CommonBase {
         */
        public KeysInterface as_KeysInterface() {
                long ret = bindings.KeysManager_as_KeysInterface(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                KeysInterface ret_hu_conv = new KeysInterface(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 99ee82ccdf8e2b9a62cdf3ce751ef502339e5e0b..93785a268249475b1923cd44230cb202e9cc3b9d 100644 (file)
@@ -39,7 +39,7 @@ public class LightningError extends CommonBase {
         */
        public ErrorAction get_action() {
                long ret = bindings.LightningError_get_action(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -57,8 +57,8 @@ public class LightningError extends CommonBase {
         */
        public static LightningError of(java.lang.String err_arg, ErrorAction action_arg) {
                long ret = bindings.LightningError_new(err_arg, action_arg.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               LightningError ret_hu_conv = new LightningError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               LightningError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LightningError(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -68,8 +68,8 @@ public class LightningError extends CommonBase {
         */
        public LightningError clone() {
                long ret = bindings.LightningError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               LightningError ret_hu_conv = new LightningError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               LightningError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LightningError(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/LockableScore.java b/src/main/java/org/ldk/structs/LockableScore.java
new file mode 100644 (file)
index 0000000..4cb8fda
--- /dev/null
@@ -0,0 +1,49 @@
+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 scorer that is accessed under a lock.
+ * 
+ * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while
+ * having shared ownership of a scorer but without requiring internal locking in [`Score`]
+ * implementations. Internal locking would be detrimental to route finding performance and could
+ * result in [`Score::channel_penalty_msat`] returning a different value for the same channel.
+ * 
+ * [`find_route`]: crate::routing::router::find_route
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class LockableScore extends CommonBase {
+       LockableScore(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.LockableScore_free(ptr); }
+       }
+
+       /**
+        * Constructs a new LockableScore from a Score
+        */
+       public static LockableScore of(Score score) {
+               long ret = bindings.LockableScore_new(score == null ? 0 : score.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               LockableScore ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LockableScore(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(score);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the LockableScore object into a byte array which can be read by LockableScore_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.LockableScore_write(this.ptr);
+               return ret;
+       }
+
+}
index 88cb0e2b8915c0140ffb7da6ad19062383379259..f75435b35cf97d3f69b9ccbc5cf8de04b2fe73cb 100644 (file)
@@ -27,7 +27,7 @@ public class MessageHandler extends CommonBase {
         */
        public ChannelMessageHandler get_chan_handler() {
                long ret = bindings.MessageHandler_get_chan_handler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -53,7 +53,7 @@ public class MessageHandler extends CommonBase {
         */
        public RoutingMessageHandler get_route_handler() {
                long ret = bindings.MessageHandler_get_route_handler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -76,8 +76,8 @@ public class MessageHandler extends CommonBase {
         */
        public static MessageHandler of(ChannelMessageHandler chan_handler_arg, RoutingMessageHandler route_handler_arg) {
                long ret = bindings.MessageHandler_new(chan_handler_arg == null ? 0 : chan_handler_arg.ptr, route_handler_arg == null ? 0 : route_handler_arg.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               MessageHandler ret_hu_conv = new MessageHandler(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MessageHandler ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MessageHandler(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(chan_handler_arg);
                ret_hu_conv.ptrs_to.add(route_handler_arg);
index 5cd35d6942851e9ef5e45950b3ec0f126439ac31..2f8e79d313cd76be3354006fd4deb990d83041de 100644 (file)
@@ -95,7 +95,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       AcceptChannel msg_hu_conv = new AcceptChannel(null, msg);
+                       AcceptChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AcceptChannel(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -113,7 +113,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       OpenChannel msg_hu_conv = new OpenChannel(null, msg);
+                       OpenChannel msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new OpenChannel(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -131,7 +131,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       FundingCreated msg_hu_conv = new FundingCreated(null, msg);
+                       FundingCreated msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingCreated(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -149,7 +149,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       FundingSigned msg_hu_conv = new FundingSigned(null, msg);
+                       FundingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingSigned(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -167,7 +167,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       FundingLocked msg_hu_conv = new FundingLocked(null, msg);
+                       FundingLocked msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new FundingLocked(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -185,7 +185,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg);
+                       AnnouncementSignatures msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new AnnouncementSignatures(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -203,7 +203,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long updates = obj.updates;
-                       CommitmentUpdate updates_hu_conv = new CommitmentUpdate(null, updates);
+                       CommitmentUpdate updates_hu_conv = null; if (updates < 0 || updates > 4096) { updates_hu_conv = new CommitmentUpdate(null, updates); }
                        updates_hu_conv.ptrs_to.add(this);
                        this.updates = updates_hu_conv;
                }
@@ -221,7 +221,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg);
+                       RevokeAndACK msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new RevokeAndACK(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -239,7 +239,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       ClosingSigned msg_hu_conv = new ClosingSigned(null, msg);
+                       ClosingSigned msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ClosingSigned(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -257,7 +257,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       Shutdown msg_hu_conv = new Shutdown(null, msg);
+                       Shutdown msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new Shutdown(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -275,7 +275,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg);
+                       ChannelReestablish msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelReestablish(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -292,11 +292,11 @@ public class MessageSendEvent extends CommonBase {
                private BroadcastChannelAnnouncement(long ptr, bindings.LDKMessageSendEvent.BroadcastChannelAnnouncement obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ChannelAnnouncement msg_hu_conv = new ChannelAnnouncement(null, msg);
+                       ChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelAnnouncement(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                        long update_msg = obj.update_msg;
-                       ChannelUpdate update_msg_hu_conv = new ChannelUpdate(null, update_msg);
+                       ChannelUpdate update_msg_hu_conv = null; if (update_msg < 0 || update_msg > 4096) { update_msg_hu_conv = new ChannelUpdate(null, update_msg); }
                        update_msg_hu_conv.ptrs_to.add(this);
                        this.update_msg = update_msg_hu_conv;
                }
@@ -309,7 +309,7 @@ public class MessageSendEvent extends CommonBase {
                private BroadcastNodeAnnouncement(long ptr, bindings.LDKMessageSendEvent.BroadcastNodeAnnouncement obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       NodeAnnouncement msg_hu_conv = new NodeAnnouncement(null, msg);
+                       NodeAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new NodeAnnouncement(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -322,7 +322,7 @@ public class MessageSendEvent extends CommonBase {
                private BroadcastChannelUpdate(long ptr, bindings.LDKMessageSendEvent.BroadcastChannelUpdate obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                       ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -340,7 +340,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                       ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -376,7 +376,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       QueryChannelRange msg_hu_conv = new QueryChannelRange(null, msg);
+                       QueryChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryChannelRange(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -394,7 +394,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       QueryShortChannelIds msg_hu_conv = new QueryShortChannelIds(null, msg);
+                       QueryShortChannelIds msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryShortChannelIds(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -412,7 +412,7 @@ public class MessageSendEvent extends CommonBase {
                        super(null, ptr);
                        this.node_id = obj.node_id;
                        long msg = obj.msg;
-                       ReplyChannelRange msg_hu_conv = new ReplyChannelRange(null, msg);
+                       ReplyChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ReplyChannelRange(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -422,7 +422,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public MessageSendEvent clone() {
                long ret = bindings.MessageSendEvent_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -433,7 +433,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_accept_channel(byte[] node_id, AcceptChannel msg) {
                long ret = bindings.MessageSendEvent_send_accept_channel(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -444,7 +444,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_open_channel(byte[] node_id, OpenChannel msg) {
                long ret = bindings.MessageSendEvent_send_open_channel(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -455,7 +455,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_funding_created(byte[] node_id, FundingCreated msg) {
                long ret = bindings.MessageSendEvent_send_funding_created(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -466,7 +466,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_funding_signed(byte[] node_id, FundingSigned msg) {
                long ret = bindings.MessageSendEvent_send_funding_signed(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -477,7 +477,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_funding_locked(byte[] node_id, FundingLocked msg) {
                long ret = bindings.MessageSendEvent_send_funding_locked(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -488,7 +488,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_announcement_signatures(byte[] node_id, AnnouncementSignatures msg) {
                long ret = bindings.MessageSendEvent_send_announcement_signatures(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -499,7 +499,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent update_htlcs(byte[] node_id, CommitmentUpdate updates) {
                long ret = bindings.MessageSendEvent_update_htlcs(node_id, updates == null ? 0 : updates.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -510,7 +510,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_revoke_and_ack(byte[] node_id, RevokeAndACK msg) {
                long ret = bindings.MessageSendEvent_send_revoke_and_ack(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -521,7 +521,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_closing_signed(byte[] node_id, ClosingSigned msg) {
                long ret = bindings.MessageSendEvent_send_closing_signed(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -532,7 +532,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_shutdown(byte[] node_id, Shutdown msg) {
                long ret = bindings.MessageSendEvent_send_shutdown(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -543,7 +543,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_channel_reestablish(byte[] node_id, ChannelReestablish msg) {
                long ret = bindings.MessageSendEvent_send_channel_reestablish(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -554,7 +554,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent broadcast_channel_announcement(ChannelAnnouncement msg, ChannelUpdate update_msg) {
                long ret = bindings.MessageSendEvent_broadcast_channel_announcement(msg == null ? 0 : msg.ptr & ~1, update_msg == null ? 0 : update_msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -565,7 +565,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent broadcast_node_announcement(NodeAnnouncement msg) {
                long ret = bindings.MessageSendEvent_broadcast_node_announcement(msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -576,7 +576,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent broadcast_channel_update(ChannelUpdate msg) {
                long ret = bindings.MessageSendEvent_broadcast_channel_update(msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -587,7 +587,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_channel_update(byte[] node_id, ChannelUpdate msg) {
                long ret = bindings.MessageSendEvent_send_channel_update(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -598,7 +598,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent handle_error(byte[] node_id, ErrorAction action) {
                long ret = bindings.MessageSendEvent_handle_error(node_id, action.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -609,7 +609,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_channel_range_query(byte[] node_id, QueryChannelRange msg) {
                long ret = bindings.MessageSendEvent_send_channel_range_query(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -620,7 +620,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_short_ids_query(byte[] node_id, QueryShortChannelIds msg) {
                long ret = bindings.MessageSendEvent_send_short_ids_query(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -631,7 +631,7 @@ public class MessageSendEvent extends CommonBase {
         */
        public static MessageSendEvent send_reply_channel_range(byte[] node_id, ReplyChannelRange msg) {
                long ret = bindings.MessageSendEvent_send_reply_channel_range(node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEvent ret_hu_conv = MessageSendEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index eca27bc3cfe96d2658af6fbb79f8f1a57542198f..5eab27cd4d16d2fcf322fcb2346c3da648c14dce 100644 (file)
@@ -19,13 +19,33 @@ public class MinFinalCltvExpiry extends CommonBase {
                if (ptr != 0) { bindings.MinFinalCltvExpiry_free(ptr); }
        }
 
+       public long get_a() {
+               long ret = bindings.MinFinalCltvExpiry_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(long val) {
+               bindings.MinFinalCltvExpiry_set_a(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new MinFinalCltvExpiry given each field
+        */
+       public static MinFinalCltvExpiry of(long a_arg) {
+               long ret = bindings.MinFinalCltvExpiry_new(a_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MinFinalCltvExpiry(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        /**
         * Creates a copy of the MinFinalCltvExpiry
         */
        public MinFinalCltvExpiry clone() {
                long ret = bindings.MinFinalCltvExpiry_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               MinFinalCltvExpiry ret_hu_conv = new MinFinalCltvExpiry(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MinFinalCltvExpiry(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 2b2acb8381d37cdde18794584f3fbb87f0a0fcd1..da40b184d900a8d90979bfa5e506dd087a2eab34 100644 (file)
@@ -26,6 +26,12 @@ public class MonitorEvent extends CommonBase {
                if (raw_val.getClass() == bindings.LDKMonitorEvent.CommitmentTxConfirmed.class) {
                        return new CommitmentTxConfirmed(ptr, (bindings.LDKMonitorEvent.CommitmentTxConfirmed)raw_val);
                }
+               if (raw_val.getClass() == bindings.LDKMonitorEvent.UpdateCompleted.class) {
+                       return new UpdateCompleted(ptr, (bindings.LDKMonitorEvent.UpdateCompleted)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKMonitorEvent.UpdateFailed.class) {
+                       return new UpdateFailed(ptr, (bindings.LDKMonitorEvent.UpdateFailed)raw_val);
+               }
                assert false; return null; // Unreachable without extending the (internal) bindings interface
        }
 
@@ -34,7 +40,7 @@ public class MonitorEvent extends CommonBase {
                private HTLCEvent(long ptr, bindings.LDKMonitorEvent.HTLCEvent obj) {
                        super(null, ptr);
                        long htlc_event = obj.htlc_event;
-                       HTLCUpdate htlc_event_hu_conv = new HTLCUpdate(null, htlc_event);
+                       HTLCUpdate htlc_event_hu_conv = null; if (htlc_event < 0 || htlc_event > 4096) { htlc_event_hu_conv = new HTLCUpdate(null, htlc_event); }
                        htlc_event_hu_conv.ptrs_to.add(this);
                        this.htlc_event = htlc_event_hu_conv;
                }
@@ -44,17 +50,49 @@ public class MonitorEvent extends CommonBase {
                private CommitmentTxConfirmed(long ptr, bindings.LDKMonitorEvent.CommitmentTxConfirmed obj) {
                        super(null, ptr);
                        long commitment_tx_confirmed = obj.commitment_tx_confirmed;
-                       OutPoint commitment_tx_confirmed_hu_conv = new OutPoint(null, commitment_tx_confirmed);
+                       OutPoint commitment_tx_confirmed_hu_conv = null; if (commitment_tx_confirmed < 0 || commitment_tx_confirmed > 4096) { 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;
                }
        }
+       public final static class UpdateCompleted extends MonitorEvent {
+               /**
+                * The funding outpoint of the [`ChannelMonitor`] that was updated
+               */
+               public final OutPoint funding_txo;
+               /**
+                * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
+                * [`ChannelMonitor::get_latest_update_id`].
+                * 
+                * Note that this should only be set to a given update's ID if all previous updates for the
+                * same [`ChannelMonitor`] have been applied and persisted.
+               */
+               public final long monitor_update_id;
+               private UpdateCompleted(long ptr, bindings.LDKMonitorEvent.UpdateCompleted obj) {
+                       super(null, ptr);
+                       long funding_txo = obj.funding_txo;
+                       OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new OutPoint(null, funding_txo); }
+                       funding_txo_hu_conv.ptrs_to.add(this);
+                       this.funding_txo = funding_txo_hu_conv;
+                       this.monitor_update_id = obj.monitor_update_id;
+               }
+       }
+       public final static class UpdateFailed extends MonitorEvent {
+               public final OutPoint update_failed;
+               private UpdateFailed(long ptr, bindings.LDKMonitorEvent.UpdateFailed obj) {
+                       super(null, ptr);
+                       long update_failed = obj.update_failed;
+                       OutPoint update_failed_hu_conv = null; if (update_failed < 0 || update_failed > 4096) { update_failed_hu_conv = new OutPoint(null, update_failed); }
+                       update_failed_hu_conv.ptrs_to.add(this);
+                       this.update_failed = update_failed_hu_conv;
+               }
+       }
        /**
         * Creates a copy of the MonitorEvent
         */
        public MonitorEvent clone() {
                long ret = bindings.MonitorEvent_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -65,7 +103,7 @@ public class MonitorEvent extends CommonBase {
         */
        public static MonitorEvent htlcevent(HTLCUpdate a) {
                long ret = bindings.MonitorEvent_htlcevent(a == null ? 0 : a.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -76,10 +114,40 @@ public class MonitorEvent extends CommonBase {
         */
        public static MonitorEvent commitment_tx_confirmed(OutPoint a) {
                long ret = bindings.MonitorEvent_commitment_tx_confirmed(a == null ? 0 : a.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Utility method to constructs a new UpdateCompleted-variant MonitorEvent
+        */
+       public static MonitorEvent update_completed(OutPoint funding_txo, long monitor_update_id) {
+               long ret = bindings.MonitorEvent_update_completed(funding_txo == null ? 0 : funding_txo.ptr & ~1, monitor_update_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
                MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
 
+       /**
+        * Utility method to constructs a new UpdateFailed-variant MonitorEvent
+        */
+       public static MonitorEvent update_failed(OutPoint a) {
+               long ret = bindings.MonitorEvent_update_failed(a == null ? 0 : a.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.MonitorEvent_write(this.ptr);
+               return ret;
+       }
+
 }
index 133845be18e50fdcc2c5a92e8f40a3c21c5695c9..cac258b2d96499e6fe761dc4f1a604348fb04d1d 100644 (file)
@@ -23,13 +23,33 @@ public class MonitorUpdateError extends CommonBase {
                if (ptr != 0) { bindings.MonitorUpdateError_free(ptr); }
        }
 
+       public String get_a() {
+               String ret = bindings.MonitorUpdateError_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(java.lang.String val) {
+               bindings.MonitorUpdateError_set_a(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new MonitorUpdateError given each field
+        */
+       public static MonitorUpdateError of(java.lang.String a_arg) {
+               long ret = bindings.MonitorUpdateError_new(a_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MonitorUpdateError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MonitorUpdateError(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        /**
         * Creates a copy of the MonitorUpdateError
         */
        public MonitorUpdateError clone() {
                long ret = bindings.MonitorUpdateError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               MonitorUpdateError ret_hu_conv = new MonitorUpdateError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MonitorUpdateError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MonitorUpdateError(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/MonitorUpdateId.java b/src/main/java/org/ldk/structs/MonitorUpdateId.java
new file mode 100644 (file)
index 0000000..8da5bb6
--- /dev/null
@@ -0,0 +1,52 @@
+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 opaque identifier describing a specific [`Persist`] method call.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class MonitorUpdateId extends CommonBase {
+       MonitorUpdateId(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.MonitorUpdateId_free(ptr); }
+       }
+
+       /**
+        * Creates a copy of the MonitorUpdateId
+        */
+       public MonitorUpdateId clone() {
+               long ret = bindings.MonitorUpdateId_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MonitorUpdateId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MonitorUpdateId(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Checks if two MonitorUpdateIds contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.MonitorUpdateId_hash(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Checks if two MonitorUpdateIds 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(MonitorUpdateId b) {
+               boolean ret = bindings.MonitorUpdateId_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+}
index 2a2539543f919227cdcb95b0aceb4356251c7d98..5a26a2a0f11525c62ecc5714ccbb9979f3a7a77c 100644 (file)
@@ -110,7 +110,7 @@ public class NetAddress extends CommonBase {
         */
        public NetAddress clone() {
                long ret = bindings.NetAddress_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -121,7 +121,7 @@ public class NetAddress extends CommonBase {
         */
        public static NetAddress ipv4(byte[] addr, short port) {
                long ret = bindings.NetAddress_ipv4(addr, port);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -132,7 +132,7 @@ public class NetAddress extends CommonBase {
         */
        public static NetAddress ipv6(byte[] addr, short port) {
                long ret = bindings.NetAddress_ipv6(addr, port);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -143,7 +143,7 @@ public class NetAddress extends CommonBase {
         */
        public static NetAddress onion_v2(byte[] addr, short port) {
                long ret = bindings.NetAddress_onion_v2(addr, port);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -154,7 +154,7 @@ public class NetAddress extends CommonBase {
         */
        public static NetAddress onion_v3(byte[] ed25519_pubkey, short checksum, byte version, short port) {
                long ret = bindings.NetAddress_onion_v3(ed25519_pubkey, checksum, version, port);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -173,7 +173,7 @@ public class NetAddress extends CommonBase {
         */
        public static Result_NetAddressDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NetAddress_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 72f6a8df97e87ea180d5c9b44e706972cb2838ca..debc8fe4bea2b512c6fdf334d4723b7f6e39c975 100644 (file)
@@ -32,30 +32,12 @@ public class NetGraphMsgHandler extends CommonBase {
         */
        public EventHandler as_EventHandler() {
                long ret = bindings.NetGraphMsgHandler_as_EventHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                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 >= 0 && 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(NetworkGraph val) {
-               bindings.NetGraphMsgHandler_set_network_graph(this.ptr, val == null ? 0 : val.ptr & ~1);
-       }
-
        /**
         * Creates a new tracker of the actual state of the network of channels and nodes,
         * assuming an existing Network Graph.
@@ -65,9 +47,10 @@ public class NetGraphMsgHandler extends CommonBase {
         */
        public static NetGraphMsgHandler of(NetworkGraph network_graph, Option_AccessZ chain_access, Logger logger) {
                long ret = bindings.NetGraphMsgHandler_new(network_graph == null ? 0 : network_graph.ptr & ~1, chain_access.ptr, logger == null ? 0 : logger.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NetGraphMsgHandler ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NetGraphMsgHandler(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(network_graph);
                ret_hu_conv.ptrs_to.add(logger);
                return ret_hu_conv;
        }
@@ -87,7 +70,7 @@ public class NetGraphMsgHandler extends CommonBase {
         */
        public RoutingMessageHandler as_RoutingMessageHandler() {
                long ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -99,7 +82,7 @@ public class NetGraphMsgHandler extends CommonBase {
         */
        public MessageSendEventsProvider as_MessageSendEventsProvider() {
                long ret = bindings.NetGraphMsgHandler_as_MessageSendEventsProvider(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 0c3c3c3806c2729e4e10750b4eeae2c09418297a..299f4547a19503de7542ee831826e365992597c7 100644 (file)
@@ -24,8 +24,8 @@ public class NetworkGraph extends CommonBase {
         */
        public NetworkGraph clone() {
                long ret = bindings.NetworkGraph_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NetworkGraph ret_hu_conv = new NetworkGraph(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NetworkGraph ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NetworkGraph(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -43,7 +43,7 @@ public class NetworkGraph extends CommonBase {
         */
        public static Result_NetworkGraphDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NetworkGraph_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,8 +53,8 @@ public class NetworkGraph extends CommonBase {
         */
        public static NetworkGraph of(byte[] genesis_hash) {
                long ret = bindings.NetworkGraph_new(genesis_hash);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NetworkGraph ret_hu_conv = new NetworkGraph(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NetworkGraph ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NetworkGraph(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -64,8 +64,8 @@ public class NetworkGraph extends CommonBase {
         */
        public ReadOnlyNetworkGraph read_only() {
                long ret = bindings.NetworkGraph_read_only(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ReadOnlyNetworkGraph ret_hu_conv = new ReadOnlyNetworkGraph(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ReadOnlyNetworkGraph ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReadOnlyNetworkGraph(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -80,7 +80,7 @@ public class NetworkGraph extends CommonBase {
         */
        public Result_NoneLightningErrorZ update_node_from_announcement(NodeAnnouncement msg) {
                long ret = bindings.NetworkGraph_update_node_from_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -94,7 +94,7 @@ public class NetworkGraph extends CommonBase {
         */
        public Result_NoneLightningErrorZ update_node_from_unsigned_announcement(UnsignedNodeAnnouncement msg) {
                long ret = bindings.NetworkGraph_update_node_from_unsigned_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -112,7 +112,7 @@ public class NetworkGraph extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -128,7 +128,7 @@ public class NetworkGraph extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -161,7 +161,7 @@ public class NetworkGraph extends CommonBase {
         */
        public Result_NoneLightningErrorZ update_channel(ChannelUpdate msg) {
                long ret = bindings.NetworkGraph_update_channel(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -174,7 +174,7 @@ public class NetworkGraph extends CommonBase {
         */
        public Result_NoneLightningErrorZ update_channel_unsigned(UnsignedChannelUpdate msg) {
                long ret = bindings.NetworkGraph_update_channel_unsigned(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
index 4c48c3056f40ce4ce187321571cad58d7d229fa5..01e3614178b62ae8facb0b60404f3db414e4d966 100644 (file)
@@ -43,7 +43,7 @@ public class NetworkUpdate extends CommonBase {
                private ChannelUpdateMessage(long ptr, bindings.LDKNetworkUpdate.ChannelUpdateMessage obj) {
                        super(null, ptr);
                        long msg = obj.msg;
-                       ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                       ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                        msg_hu_conv.ptrs_to.add(this);
                        this.msg = msg_hu_conv;
                }
@@ -85,7 +85,7 @@ public class NetworkUpdate extends CommonBase {
         */
        public NetworkUpdate clone() {
                long ret = bindings.NetworkUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -96,7 +96,7 @@ public class NetworkUpdate extends CommonBase {
         */
        public static NetworkUpdate channel_update_message(ChannelUpdate msg) {
                long ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -107,7 +107,7 @@ public class NetworkUpdate extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -118,7 +118,7 @@ public class NetworkUpdate extends CommonBase {
         */
        public static NetworkUpdate node_failure(byte[] node_id, boolean is_permanent) {
                long ret = bindings.NetworkUpdate_node_failure(node_id, is_permanent);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 8c65c84e8c7dd30a78329acb84be04f09bde7d1a..40c01d80ac1a3c7a13b9827b078aaed972af45dd 100644 (file)
@@ -39,8 +39,8 @@ public class NodeAnnouncement extends CommonBase {
         */
        public UnsignedNodeAnnouncement get_contents() {
                long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class NodeAnnouncement extends CommonBase {
         */
        public static NodeAnnouncement of(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) {
                long ret = bindings.NodeAnnouncement_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -68,8 +68,8 @@ public class NodeAnnouncement extends CommonBase {
         */
        public NodeAnnouncement clone() {
                long ret = bindings.NodeAnnouncement_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -87,7 +87,7 @@ public class NodeAnnouncement extends CommonBase {
         */
        public static Result_NodeAnnouncementDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeAnnouncement_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 040e871988dcfba0bc7798cd439f20e0370d019a..f0a745f9230d95ed6d7121a4e1b963c0c71d0b3a 100644 (file)
@@ -24,8 +24,8 @@ public class NodeAnnouncementInfo extends CommonBase {
         */
        public NodeFeatures get_features() {
                long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -106,8 +106,8 @@ public class NodeAnnouncementInfo extends CommonBase {
        @Nullable
        public NodeAnnouncement get_announcement_message() {
                long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncement ret_hu_conv = new NodeAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -129,8 +129,8 @@ public class NodeAnnouncementInfo extends CommonBase {
         */
        public static NodeAnnouncementInfo of(NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, byte[] alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
                long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, rgb_arg, alias_arg, addresses_arg != null ? Arrays.stream(addresses_arg).mapToLong(addresses_arg_conv_12 -> addresses_arg_conv_12.ptr).toArray() : null, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -140,8 +140,8 @@ public class NodeAnnouncementInfo extends CommonBase {
         */
        public NodeAnnouncementInfo clone() {
                long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -159,7 +159,7 @@ public class NodeAnnouncementInfo extends CommonBase {
         */
        public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeAnnouncementInfo_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c41109307d74b2f53d366d9cec3f311833883256..ebd78144b187394dd7c8441ff753908cf3bbebd5 100644 (file)
@@ -35,8 +35,8 @@ public class NodeFeatures extends CommonBase {
         */
        public NodeFeatures clone() {
                long ret = bindings.NodeFeatures_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -46,8 +46,8 @@ public class NodeFeatures extends CommonBase {
         */
        public static NodeFeatures empty() {
                long ret = bindings.NodeFeatures_empty();
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class NodeFeatures extends CommonBase {
         */
        public static NodeFeatures known() {
                long ret = bindings.NodeFeatures_known();
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -93,7 +93,7 @@ public class NodeFeatures extends CommonBase {
         */
        public static Result_NodeFeaturesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeFeatures_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeFeaturesDecodeErrorZ ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a878cb5aaa1fd7fbc440776d8801267f21930edf..e74d649ae688fa69a0c5b9770ee08929feaae4e4 100644 (file)
@@ -24,8 +24,8 @@ public class NodeId extends CommonBase {
         */
        public NodeId clone() {
                long ret = bindings.NodeId_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeId ret_hu_conv = new NodeId(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -35,8 +35,8 @@ public class NodeId extends CommonBase {
         */
        public static NodeId from_pubkey(byte[] pubkey) {
                long ret = bindings.NodeId_from_pubkey(pubkey);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeId ret_hu_conv = new NodeId(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -70,7 +70,7 @@ public class NodeId extends CommonBase {
         */
        public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeId_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index ad0b48482bec82bdb4793df0520e7b4e1cb57db9..f599db754cf56009b06d35538619d02cf06ebef1 100644 (file)
@@ -36,8 +36,8 @@ public class NodeInfo extends CommonBase {
        @Nullable
        public RoutingFees get_lowest_inbound_channel_fees() {
                long ret = bindings.NodeInfo_get_lowest_inbound_channel_fees(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RoutingFees ret_hu_conv = new RoutingFees(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -63,8 +63,8 @@ public class NodeInfo extends CommonBase {
        @Nullable
        public NodeAnnouncementInfo get_announcement_info() {
                long ret = bindings.NodeInfo_get_announcement_info(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeAnnouncementInfo ret_hu_conv = new NodeAnnouncementInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncementInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -85,8 +85,8 @@ public class NodeInfo extends CommonBase {
         */
        public static NodeInfo of(long[] channels_arg, RoutingFees lowest_inbound_channel_fees_arg, NodeAnnouncementInfo announcement_info_arg) {
                long ret = bindings.NodeInfo_new(channels_arg, lowest_inbound_channel_fees_arg == null ? 0 : lowest_inbound_channel_fees_arg.ptr & ~1, announcement_info_arg == null ? 0 : announcement_info_arg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeInfo ret_hu_conv = new NodeInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -96,8 +96,8 @@ public class NodeInfo extends CommonBase {
         */
        public NodeInfo clone() {
                long ret = bindings.NodeInfo_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeInfo ret_hu_conv = new NodeInfo(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeInfo(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -115,7 +115,7 @@ public class NodeInfo extends CommonBase {
         */
        public static Result_NodeInfoDecodeErrorZ read(byte[] ser) {
                long ret = bindings.NodeInfo_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 19231f6708ff7ed0a367aff0370d9892532500be..ff78eea1094e84df8136624cea66e83e956fe437 100644 (file)
@@ -294,8 +294,8 @@ public class OpenChannel extends CommonBase {
         */
        public OpenChannel clone() {
                long ret = bindings.OpenChannel_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OpenChannel ret_hu_conv = new OpenChannel(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OpenChannel(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -313,7 +313,7 @@ public class OpenChannel extends CommonBase {
         */
        public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
                long ret = bindings.OpenChannel_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8ddfe8cd0aa15b7fcdfd6ff850169e2a9f097e1c..30119e33ad9e57eaae15af74c6657f4c213ed343 100644 (file)
@@ -49,7 +49,7 @@ public class Option_AccessZ extends CommonBase {
         */
        public static Option_AccessZ some(Access o) {
                long ret = bindings.COption_AccessZ_some(o == null ? 0 : o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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);
@@ -61,7 +61,7 @@ public class Option_AccessZ extends CommonBase {
         */
        public static Option_AccessZ none() {
                long ret = bindings.COption_AccessZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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;
index 597c17a0ea8ead68dc436bc1c4d958283ebc1911..4c07583c6934ad18eea27993b9bdc333bc674017 100644 (file)
@@ -49,7 +49,7 @@ public class Option_C2Tuple_usizeTransactionZZ extends CommonBase {
         */
        public static Option_C2Tuple_usizeTransactionZZ some(TwoTuple_usizeTransactionZ o) {
                long ret = bindings.COption_C2Tuple_usizeTransactionZZ_some(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_C2Tuple_usizeTransactionZZ ret_hu_conv = Option_C2Tuple_usizeTransactionZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -60,7 +60,7 @@ public class Option_C2Tuple_usizeTransactionZZ extends CommonBase {
         */
        public static Option_C2Tuple_usizeTransactionZZ none() {
                long ret = bindings.COption_C2Tuple_usizeTransactionZZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_C2Tuple_usizeTransactionZZ ret_hu_conv = Option_C2Tuple_usizeTransactionZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -72,7 +72,7 @@ public class Option_C2Tuple_usizeTransactionZZ extends CommonBase {
         */
        public Option_C2Tuple_usizeTransactionZZ clone() {
                long ret = bindings.COption_C2Tuple_usizeTransactionZZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_C2Tuple_usizeTransactionZZ ret_hu_conv = Option_C2Tuple_usizeTransactionZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 22a3886369c585ce5c4fefb0f6c54917b9f36584..9ae23246e3627ce0706f5a1367c46db59dd35809 100644 (file)
@@ -54,7 +54,7 @@ public class Option_CVec_NetAddressZZ extends CommonBase {
         */
        public static Option_CVec_NetAddressZZ some(NetAddress[] o) {
                long ret = bindings.COption_CVec_NetAddressZZ_some(o != null ? Arrays.stream(o).mapToLong(o_conv_12 -> o_conv_12.ptr).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_CVec_NetAddressZZ ret_hu_conv = Option_CVec_NetAddressZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -65,7 +65,7 @@ public class Option_CVec_NetAddressZZ extends CommonBase {
         */
        public static Option_CVec_NetAddressZZ none() {
                long ret = bindings.COption_CVec_NetAddressZZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_CVec_NetAddressZZ ret_hu_conv = Option_CVec_NetAddressZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -77,7 +77,7 @@ public class Option_CVec_NetAddressZZ extends CommonBase {
         */
        public Option_CVec_NetAddressZZ clone() {
                long ret = bindings.COption_CVec_NetAddressZZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_CVec_NetAddressZZ ret_hu_conv = Option_CVec_NetAddressZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 2aa00915444ac8ce736d48791dc49a8324578f7f..ac669f028aa4c7f0a13f60f5f6ff0930d8e01930 100644 (file)
@@ -49,7 +49,7 @@ public class Option_FilterZ extends CommonBase {
         */
        public static Option_FilterZ some(Filter o) {
                long ret = bindings.COption_FilterZ_some(o == null ? 0 : o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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);
@@ -61,7 +61,7 @@ public class Option_FilterZ extends CommonBase {
         */
        public static Option_FilterZ none() {
                long ret = bindings.COption_FilterZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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;
index 37435f060ddc91d5cd3693bf848631a3525f68bd..6657b05e56058ae291c9b97afb45e4c3233e6bd1 100644 (file)
@@ -49,7 +49,7 @@ public class Option_NetworkUpdateZ extends CommonBase {
         */
        public static Option_NetworkUpdateZ some(NetworkUpdate o) {
                long ret = bindings.COption_NetworkUpdateZ_some(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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;
@@ -60,7 +60,7 @@ public class Option_NetworkUpdateZ extends CommonBase {
         */
        public static Option_NetworkUpdateZ none() {
                long ret = bindings.COption_NetworkUpdateZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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;
@@ -72,7 +72,7 @@ public class Option_NetworkUpdateZ extends CommonBase {
         */
        public Option_NetworkUpdateZ clone() {
                long ret = bindings.COption_NetworkUpdateZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_NetworkUpdateZ ret_hu_conv = Option_NetworkUpdateZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 8df2c9949945726384f8a6229ed802f6f6a23be8..fffa4bb0bec7c81d94399c15e8634bf8d73fe486 100644 (file)
@@ -49,7 +49,7 @@ public class Option_TypeZ extends CommonBase {
         */
        public static Option_TypeZ some(Type o) {
                long ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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);
@@ -61,7 +61,7 @@ public class Option_TypeZ extends CommonBase {
         */
        public static Option_TypeZ none() {
                long ret = bindings.COption_TypeZ_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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;
@@ -73,7 +73,7 @@ public class Option_TypeZ extends CommonBase {
         */
        public Option_TypeZ clone() {
                long ret = bindings.COption_TypeZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 4068a379d4c5dddb3c8f7898a67cefd71d268a67..1ed16f3f8acb7a777724f8cc993eb27eb28cfdc8 100644 (file)
@@ -46,7 +46,7 @@ public class Option_u16Z extends CommonBase {
         */
        public static Option_u16Z some(short o) {
                long ret = bindings.COption_u16Z_some(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -57,7 +57,7 @@ public class Option_u16Z extends CommonBase {
         */
        public static Option_u16Z none() {
                long ret = bindings.COption_u16Z_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -69,7 +69,7 @@ public class Option_u16Z extends CommonBase {
         */
        public Option_u16Z clone() {
                long ret = bindings.COption_u16Z_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 8e488657f7e45dc5c58c811e9234c517b316e15a..3c4fcd68799fbed6858d2c3d22f44ef3140674f1 100644 (file)
@@ -46,7 +46,7 @@ public class Option_u32Z extends CommonBase {
         */
        public static Option_u32Z some(int o) {
                long ret = bindings.COption_u32Z_some(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -57,7 +57,7 @@ public class Option_u32Z extends CommonBase {
         */
        public static Option_u32Z none() {
                long ret = bindings.COption_u32Z_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -69,7 +69,7 @@ public class Option_u32Z extends CommonBase {
         */
        public Option_u32Z clone() {
                long ret = bindings.COption_u32Z_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 3de70c699ce29b157ececbe8097d8c91bbf1c2e1..e4689c89333c7e9f0510d2da62b2cb0ed1c2b040 100644 (file)
@@ -46,7 +46,7 @@ public class Option_u64Z extends CommonBase {
         */
        public static Option_u64Z some(long o) {
                long ret = bindings.COption_u64Z_some(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -57,7 +57,7 @@ public class Option_u64Z extends CommonBase {
         */
        public static Option_u64Z none() {
                long ret = bindings.COption_u64Z_none();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -69,7 +69,7 @@ public class Option_u64Z extends CommonBase {
         */
        public Option_u64Z clone() {
                long ret = bindings.COption_u64Z_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 0fc805c814c1c82aa9bdad9e81ab423e6a4c6854..edb136126a7d606f93cd3f0b8e3e3e83c589d591 100644 (file)
@@ -57,8 +57,8 @@ public class OutPoint extends CommonBase {
         */
        public static OutPoint of(byte[] txid_arg, short index_arg) {
                long ret = bindings.OutPoint_new(txid_arg, index_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -68,8 +68,8 @@ public class OutPoint extends CommonBase {
         */
        public OutPoint clone() {
                long ret = bindings.OutPoint_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -114,7 +114,7 @@ public class OutPoint extends CommonBase {
         */
        public static Result_OutPointDecodeErrorZ read(byte[] ser) {
                long ret = bindings.OutPoint_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Payee.java b/src/main/java/org/ldk/structs/Payee.java
new file mode 100644 (file)
index 0000000..922f488
--- /dev/null
@@ -0,0 +1,191 @@
+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 recipient of a payment.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class Payee extends CommonBase {
+       Payee(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.Payee_free(ptr); }
+       }
+
+       /**
+        * The node id of the payee.
+        */
+       public byte[] get_pubkey() {
+               byte[] ret = bindings.Payee_get_pubkey(this.ptr);
+               return ret;
+       }
+
+       /**
+        * The node id of the payee.
+        */
+       public void set_pubkey(byte[] val) {
+               bindings.Payee_set_pubkey(this.ptr, val);
+       }
+
+       /**
+        * Features supported by the payee.
+        * 
+        * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
+        * does not contain any features.
+        * 
+        * [`for_keysend`]: Self::for_keysend
+        * 
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       @Nullable
+       public InvoiceFeatures get_features() {
+               long ret = bindings.Payee_get_features(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Features supported by the payee.
+        * 
+        * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
+        * does not contain any features.
+        * 
+        * [`for_keysend`]: Self::for_keysend
+        * 
+        * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       public void set_features(@Nullable InvoiceFeatures val) {
+               bindings.Payee_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
+       /**
+        * Hints for routing to the payee, containing channels connecting the payee to public nodes.
+        */
+       public RouteHint[] get_route_hints() {
+               long[] ret = bindings.Payee_get_route_hints(this.ptr);
+               RouteHint[] ret_conv_11_arr = new RouteHint[ret.length];
+               for (int l = 0; l < ret.length; l++) {
+                       long ret_conv_11 = ret[l];
+                       RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new RouteHint(null, ret_conv_11); }
+                       ret_conv_11_hu_conv.ptrs_to.add(this);
+                       ret_conv_11_arr[l] = ret_conv_11_hu_conv;
+               }
+               return ret_conv_11_arr;
+       }
+
+       /**
+        * Hints for routing to the payee, containing channels connecting the payee to public nodes.
+        */
+       public void set_route_hints(RouteHint[] val) {
+               bindings.Payee_set_route_hints(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_11 -> val_conv_11 == null ? 0 : val_conv_11.ptr & ~1).toArray() : null);
+       }
+
+       /**
+        * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
+        */
+       public Option_u64Z get_expiry_time() {
+               long ret = bindings.Payee_get_expiry_time(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
+        */
+       public void set_expiry_time(Option_u64Z val) {
+               bindings.Payee_set_expiry_time(this.ptr, val.ptr);
+       }
+
+       /**
+        * Constructs a new Payee given each field
+        */
+       public static Payee of(byte[] pubkey_arg, InvoiceFeatures features_arg, RouteHint[] route_hints_arg, Option_u64Z expiry_time_arg) {
+               long ret = bindings.Payee_new(pubkey_arg, features_arg == null ? 0 : features_arg.ptr & ~1, route_hints_arg != null ? Arrays.stream(route_hints_arg).mapToLong(route_hints_arg_conv_11 -> route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr & ~1).toArray() : null, expiry_time_arg.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a copy of the Payee
+        */
+       public Payee clone() {
+               long ret = bindings.Payee_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Checks if two Payees contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.Payee_hash(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Checks if two Payees 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(Payee b) {
+               boolean ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+       /**
+        * Serialize the Payee object into a byte array which can be read by Payee_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.Payee_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a Payee from a byte array, created by Payee_write
+        */
+       public static Result_PayeeDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.Payee_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a payee with the node id of the given `pubkey`.
+        */
+       public static Payee from_node_id(byte[] pubkey) {
+               long ret = bindings.Payee_from_node_id(pubkey);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a payee with the node id of the given `pubkey` to use for keysend payments.
+        */
+       public static Payee for_keysend(byte[] pubkey) {
+               long ret = bindings.Payee_for_keysend(pubkey);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+}
index b1251eb75f51f354eef9bb98aa24104a12f159c6..5bf36b0a510cd16cdc08b6422390ede4de8de462 100644 (file)
@@ -19,13 +19,33 @@ public class PayeePubKey extends CommonBase {
                if (ptr != 0) { bindings.PayeePubKey_free(ptr); }
        }
 
+       public byte[] get_a() {
+               byte[] ret = bindings.PayeePubKey_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(byte[] val) {
+               bindings.PayeePubKey_set_a(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new PayeePubKey given each field
+        */
+       public static PayeePubKey of(byte[] a_arg) {
+               long ret = bindings.PayeePubKey_new(a_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PayeePubKey(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        /**
         * Creates a copy of the PayeePubKey
         */
        public PayeePubKey clone() {
                long ret = bindings.PayeePubKey_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PayeePubKey ret_hu_conv = new PayeePubKey(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PayeePubKey(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Payer.java b/src/main/java/org/ldk/structs/Payer.java
new file mode 100644 (file)
index 0000000..bb7c58c
--- /dev/null
@@ -0,0 +1,121 @@
+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 trait defining behavior of an [`Invoice`] payer.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class Payer extends CommonBase {
+       final bindings.LDKPayer bindings_instance;
+       Payer(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
+       private Payer(bindings.LDKPayer arg) {
+               super(bindings.LDKPayer_new(arg));
+               this.ptrs_to.add(arg);
+               this.bindings_instance = arg;
+       }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.Payer_free(ptr); } super.finalize();
+       }
+
+       public static interface PayerInterface {
+               /**
+                * Returns the payer's node id.
+                */
+               byte[] node_id();
+               /**
+                * Returns the payer's channels.
+                */
+               ChannelDetails[] first_hops();
+               /**
+                * Sends a payment over the Lightning Network using the given [`Route`].
+                * 
+                * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
+                */
+               Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, byte[] payment_secret);
+               /**
+                * Retries a failed payment path for the [`PaymentId`] using the given [`Route`].
+                */
+               Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id);
+       }
+       private static class LDKPayerHolder { Payer held; }
+       public static Payer new_impl(PayerInterface arg) {
+               final LDKPayerHolder impl_holder = new LDKPayerHolder();
+               impl_holder.held = new Payer(new bindings.LDKPayer() {
+                       @Override public byte[] node_id() {
+                               byte[] ret = arg.node_id();
+                               return ret;
+                       }
+                       @Override public long[] first_hops() {
+                               ChannelDetails[] ret = arg.first_hops();
+                               long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_16 -> ret_conv_16 == null ? 0 : ret_conv_16.ptr & ~1).toArray() : null;
+                               return result;
+                       }
+                       @Override public long send_payment(long route, byte[] payment_hash, byte[] payment_secret) {
+                               Route route_hu_conv = null; if (route < 0 || route > 4096) { route_hu_conv = new Route(null, route); }
+                               Result_PaymentIdPaymentSendFailureZ ret = arg.send_payment(route_hu_conv, payment_hash, payment_secret);
+                               long result = ret != null ? ret.ptr : 0;
+                               return result;
+                       }
+                       @Override public long retry_payment(long route, byte[] payment_id) {
+                               Route route_hu_conv = null; if (route < 0 || route > 4096) { route_hu_conv = new Route(null, route); }
+                               Result_NonePaymentSendFailureZ ret = arg.retry_payment(route_hu_conv, payment_id);
+                               long result = ret != null ? ret.ptr : 0;
+                               return result;
+                       }
+               });
+               return impl_holder.held;
+       }
+       /**
+        * Returns the payer's node id.
+        */
+       public byte[] node_id() {
+               byte[] ret = bindings.Payer_node_id(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Returns the payer's channels.
+        */
+       public ChannelDetails[] first_hops() {
+               long[] ret = bindings.Payer_first_hops(this.ptr);
+               ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
+               for (int q = 0; q < ret.length; q++) {
+                       long ret_conv_16 = ret[q];
+                       ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(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;
+       }
+
+       /**
+        * Sends a payment over the Lightning Network using the given [`Route`].
+        * 
+        * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       public Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, @Nullable byte[] payment_secret) {
+               long ret = bindings.Payer_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_hash, payment_secret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
+               this.ptrs_to.add(route);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Retries a failed payment path for the [`PaymentId`] using the given [`Route`].
+        */
+       public Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id) {
+               long ret = bindings.Payer_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
+               this.ptrs_to.add(route);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/src/main/java/org/ldk/structs/PaymentError.java b/src/main/java/org/ldk/structs/PaymentError.java
new file mode 100644 (file)
index 0000000..ca806da
--- /dev/null
@@ -0,0 +1,106 @@
+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 error that may occur when making a payment.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class PaymentError extends CommonBase {
+       private PaymentError(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.PaymentError_free(ptr); }
+       }
+       static PaymentError constr_from_ptr(long ptr) {
+               bindings.LDKPaymentError raw_val = bindings.LDKPaymentError_ref_from_ptr(ptr);
+               if (raw_val.getClass() == bindings.LDKPaymentError.Invoice.class) {
+                       return new Invoice(ptr, (bindings.LDKPaymentError.Invoice)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKPaymentError.Routing.class) {
+                       return new Routing(ptr, (bindings.LDKPaymentError.Routing)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKPaymentError.Sending.class) {
+                       return new Sending(ptr, (bindings.LDKPaymentError.Sending)raw_val);
+               }
+               assert false; return null; // Unreachable without extending the (internal) bindings interface
+       }
+
+       public final static class Invoice extends PaymentError {
+               public final String invoice;
+               private Invoice(long ptr, bindings.LDKPaymentError.Invoice obj) {
+                       super(null, ptr);
+                       this.invoice = obj.invoice;
+               }
+       }
+       public final static class Routing extends PaymentError {
+               public final LightningError routing;
+               private Routing(long ptr, bindings.LDKPaymentError.Routing obj) {
+                       super(null, ptr);
+                       long routing = obj.routing;
+                       LightningError routing_hu_conv = null; if (routing < 0 || routing > 4096) { routing_hu_conv = new LightningError(null, routing); }
+                       routing_hu_conv.ptrs_to.add(this);
+                       this.routing = routing_hu_conv;
+               }
+       }
+       public final static class Sending extends PaymentError {
+               public final PaymentSendFailure sending;
+               private Sending(long ptr, bindings.LDKPaymentError.Sending obj) {
+                       super(null, ptr);
+                       long sending = obj.sending;
+                       PaymentSendFailure sending_hu_conv = PaymentSendFailure.constr_from_ptr(sending);
+                       sending_hu_conv.ptrs_to.add(this);
+                       this.sending = sending_hu_conv;
+               }
+       }
+       /**
+        * Creates a copy of the PaymentError
+        */
+       public PaymentError clone() {
+               long ret = bindings.PaymentError_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Utility method to constructs a new Invoice-variant PaymentError
+        */
+       public static PaymentError invoice(java.lang.String a) {
+               long ret = bindings.PaymentError_invoice(a);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Utility method to constructs a new Routing-variant PaymentError
+        */
+       public static PaymentError routing(LightningError a) {
+               long ret = bindings.PaymentError_routing(a == null ? 0 : a.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Utility method to constructs a new Sending-variant PaymentError
+        */
+       public static PaymentError sending(PaymentSendFailure a) {
+               long ret = bindings.PaymentError_sending(a.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PaymentError ret_hu_conv = PaymentError.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/PaymentId.java b/src/main/java/org/ldk/structs/PaymentId.java
deleted file mode 100644 (file)
index 21c1c75..0000000
+++ /dev/null
@@ -1,70 +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 payment identifier used to uniquely identify a payment to LDK.
- */
-@SuppressWarnings("unchecked") // We correctly assign various generic arrays
-public class PaymentId extends CommonBase {
-       PaymentId(Object _dummy, long ptr) { super(ptr); }
-       @Override @SuppressWarnings("deprecation")
-       protected void finalize() throws Throwable {
-               super.finalize();
-               if (ptr != 0) { bindings.PaymentId_free(ptr); }
-       }
-
-       /**
-        * Checks if two PaymentIds contain equal inner contents.
-        */
-       public long hash() {
-               long ret = bindings.PaymentId_hash(this.ptr);
-               return ret;
-       }
-
-       /**
-        * Creates a copy of the PaymentId
-        */
-       public PaymentId clone() {
-               long ret = bindings.PaymentId_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PaymentId ret_hu_conv = new PaymentId(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Checks if two PaymentIds 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(PaymentId b) {
-               boolean ret = bindings.PaymentId_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
-               this.ptrs_to.add(b);
-               return ret;
-       }
-
-       /**
-        * Serialize the PaymentId object into a byte array which can be read by PaymentId_read
-        */
-       public byte[] write() {
-               byte[] ret = bindings.PaymentId_write(this.ptr);
-               return ret;
-       }
-
-       /**
-        * Read a PaymentId from a byte array, created by PaymentId_write
-        */
-       public static Result_PaymentIdDecodeErrorZ read(byte[] ser) {
-               long ret = bindings.PaymentId_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
index abc8a675a981e536f723cfd9fa9530e556225425..9290a3c529b8c9e7cb9af9cb39ea628c5d25f2cd 100644 (file)
@@ -85,7 +85,7 @@ public class PaymentPurpose extends CommonBase {
         */
        public PaymentPurpose clone() {
                long ret = bindings.PaymentPurpose_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -96,7 +96,7 @@ public class PaymentPurpose extends CommonBase {
         */
        public static PaymentPurpose invoice_payment(byte[] payment_preimage, byte[] payment_secret, long user_payment_id) {
                long ret = bindings.PaymentPurpose_invoice_payment(payment_preimage, payment_secret, user_payment_id);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -107,7 +107,7 @@ public class PaymentPurpose extends CommonBase {
         */
        public static PaymentPurpose spontaneous_payment(byte[] a) {
                long ret = bindings.PaymentPurpose_spontaneous_payment(a);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentPurpose ret_hu_conv = PaymentPurpose.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 9f159e2c5bff378c46c8041d98497f3458b7e66f..384d737a8d9801953cfa35e2fb66e23ddf77993a 100644 (file)
@@ -77,17 +77,37 @@ public class PaymentSendFailure extends CommonBase {
                }
        }
        public final static class PartialFailure extends PaymentSendFailure {
-               public final Result_NoneAPIErrorZ[] partial_failure;
+               /**
+                * The errors themselves, in the same order as the route hops.
+               */
+               public final Result_NoneAPIErrorZ[] results;
+               /**
+                * If some paths failed without irrevocably committing to the new HTLC(s), this will
+                * contain a [`RouteParameters`] object which can be used to calculate a new route that
+                * will pay all remaining unpaid balance.
+                * 
+                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+               */
+               @Nullable public final RouteParameters failed_paths_retry;
+               /**
+                * The payment id for the payment, which is now at least partially pending.
+               */
+               public final byte[] payment_id;
                private PartialFailure(long ptr, bindings.LDKPaymentSendFailure.PartialFailure obj) {
                        super(null, ptr);
-                       long[] partial_failure = obj.partial_failure;
-                       Result_NoneAPIErrorZ[] partial_failure_conv_22_arr = new Result_NoneAPIErrorZ[partial_failure.length];
-                       for (int w = 0; w < partial_failure.length; w++) {
-                               long partial_failure_conv_22 = partial_failure[w];
-                               Result_NoneAPIErrorZ partial_failure_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(partial_failure_conv_22);
-                               partial_failure_conv_22_arr[w] = partial_failure_conv_22_hu_conv;
+                       long[] results = obj.results;
+                       Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results.length];
+                       for (int w = 0; w < results.length; w++) {
+                               long results_conv_22 = results[w];
+                               Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
+                               results_conv_22_arr[w] = results_conv_22_hu_conv;
                        }
-                       this.partial_failure = partial_failure_conv_22_arr;
+                       this.results = results_conv_22_arr;
+                       long failed_paths_retry = obj.failed_paths_retry;
+                       RouteParameters failed_paths_retry_hu_conv = null; if (failed_paths_retry < 0 || failed_paths_retry > 4096) { failed_paths_retry_hu_conv = new RouteParameters(null, failed_paths_retry); }
+                       failed_paths_retry_hu_conv.ptrs_to.add(this);
+                       this.failed_paths_retry = failed_paths_retry_hu_conv;
+                       this.payment_id = obj.payment_id;
                }
        }
        /**
@@ -95,7 +115,7 @@ public class PaymentSendFailure extends CommonBase {
         */
        public PaymentSendFailure clone() {
                long ret = bindings.PaymentSendFailure_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -106,7 +126,7 @@ public class PaymentSendFailure extends CommonBase {
         */
        public static PaymentSendFailure parameter_error(APIError a) {
                long ret = bindings.PaymentSendFailure_parameter_error(a.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -117,7 +137,7 @@ public class PaymentSendFailure extends CommonBase {
         */
        public static PaymentSendFailure path_parameter_error(Result_NoneAPIErrorZ[] a) {
                long ret = bindings.PaymentSendFailure_path_parameter_error(a != null ? Arrays.stream(a).mapToLong(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -128,7 +148,7 @@ public class PaymentSendFailure extends CommonBase {
         */
        public static PaymentSendFailure all_failed_retry_safe(APIError[] a) {
                long ret = bindings.PaymentSendFailure_all_failed_retry_safe(a != null ? Arrays.stream(a).mapToLong(a_conv_10 -> a_conv_10.ptr).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -137,9 +157,9 @@ public class PaymentSendFailure extends CommonBase {
        /**
         * Utility method to constructs a new PartialFailure-variant PaymentSendFailure
         */
-       public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] a) {
-               long ret = bindings.PaymentSendFailure_partial_failure(a != null ? Arrays.stream(a).mapToLong(a_conv_22 -> a_conv_22 != null ? a_conv_22.ptr : 0).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static PaymentSendFailure partial_failure(Result_NoneAPIErrorZ[] results, RouteParameters failed_paths_retry, byte[] payment_id) {
+               long ret = bindings.PaymentSendFailure_partial_failure(results != null ? Arrays.stream(results).mapToLong(results_conv_22 -> results_conv_22 != null ? results_conv_22.ptr : 0).toArray() : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr & ~1, payment_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index a398ddb61cf412aebbd5d38a9c20a94fd85954a0..ab0f5686b1e9781751777eaf34a134576692f550 100644 (file)
@@ -43,8 +43,8 @@ public class PeerHandleError extends CommonBase {
         */
        public static PeerHandleError of(boolean no_connection_possible_arg) {
                long ret = bindings.PeerHandleError_new(no_connection_possible_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PeerHandleError ret_hu_conv = new PeerHandleError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PeerHandleError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PeerHandleError(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -54,8 +54,8 @@ public class PeerHandleError extends CommonBase {
         */
        public PeerHandleError clone() {
                long ret = bindings.PeerHandleError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PeerHandleError ret_hu_conv = new PeerHandleError(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PeerHandleError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PeerHandleError(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 285ac3bcfd8198c32c0f7e4c35f3586f2dc2285c..e24a5356726d526e4806d75c1165db130a68c747 100644 (file)
@@ -44,8 +44,8 @@ public class PeerManager extends CommonBase {
         */
        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 >= 0 && ret < 1024) { return null; }
-               PeerManager ret_hu_conv = new PeerManager(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PeerManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { 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);
@@ -80,7 +80,7 @@ public class PeerManager extends CommonBase {
         */
        public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) {
                long ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(descriptor);
                return ret_hu_conv;
@@ -101,7 +101,7 @@ public class PeerManager extends CommonBase {
         */
        public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
                long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(descriptor);
                return ret_hu_conv;
@@ -123,7 +123,7 @@ public class PeerManager extends CommonBase {
         */
        public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
                long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -146,7 +146,7 @@ public class PeerManager extends CommonBase {
         */
        public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) {
                long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -192,6 +192,15 @@ public class PeerManager extends CommonBase {
                bindings.PeerManager_disconnect_by_node_id(this.ptr, node_id, no_connection_possible);
        }
 
+       /**
+        * Disconnects all currently-connected peers. This is useful on platforms where there may be
+        * an indication that TCP sockets have stalled even if we weren't around to time them out
+        * using regular ping/pongs.
+        */
+       public void disconnect_all_peers() {
+               bindings.PeerManager_disconnect_all_peers(this.ptr);
+       }
+
        /**
         * Send pings to each peer and disconnect those which did not respond to the last round of
         * pings.
index f424851a8d37e88b3e22351d27ba72abdedd5022..335576fca31b1d18820009aaef758c8c06f2678c 100644 (file)
@@ -10,14 +10,22 @@ import javax.annotation.Nullable;
  * `Persist` defines behavior for persisting channel monitors: this could mean
  * writing once to disk, and/or uploading to one or more backup services.
  * 
- * Note that for every new monitor, you **must** persist the new `ChannelMonitor`
- * to disk/backups. And, on every update, you **must** persist either the
- * `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk
- * of situations such as revoking a transaction, then crashing before this
- * revocation can be persisted, then unintentionally broadcasting a revoked
- * transaction and losing money. This is a risk because previous channel states
- * are toxic, so it's important that whatever channel state is persisted is
- * kept up-to-date.
+ * Each method can return three possible values:
+ * If persistence (including any relevant `fsync()` calls) happens immediately, the
+ * implementation should return `Ok(())`, indicating normal channel operation should continue.
+ * If persistence happens asynchronously, implementations should first ensure the
+ * [`ChannelMonitor`] or [`ChannelMonitorUpdate`] are written durably to disk, and then return
+ * `Err(ChannelMonitorUpdateErr::TemporaryFailure)` while the update continues in the
+ * background. Once the update completes, [`ChainMonitor::channel_monitor_updated`] should be
+ * called with the corresponding [`MonitorUpdateId`].
+ * 
+ * Note that unlike the direct [`chain::Watch`] interface,
+ * [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs.
+ * 
+ * If persistence fails for some reason, implementations should return
+ * `Err(ChannelMonitorUpdateErr::PermanentFailure)`, in which case the channel will likely be
+ * closed without broadcasting the latest state. See
+ * [`ChannelMonitorUpdateErr::PermanentFailure`] for more details.
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class Persist extends CommonBase {
@@ -35,25 +43,36 @@ public class Persist extends CommonBase {
 
        public static interface PersistInterface {
                /**
-                * Persist a new channel's data. The data can be stored any way you want, but
-                * the identifier provided by Rust-Lightning is the channel's outpoint (and
-                * it is up to you to maintain a correct mapping between the outpoint and the
-                * stored channel data). Note that you **must** persist every new monitor to
-                * disk. See the `Persist` trait documentation for more details.
+                * Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is
+                * called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup.
+                * 
+                * The data can be stored any way you want, but the identifier provided by LDK is the
+                * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint
+                * and the stored channel data). Note that you **must** persist every new monitor to disk.
+                * 
+                * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`],
+                * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`].
                 * 
                 * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`
                 * and [`ChannelMonitorUpdateErr`] for requirements when returning errors.
                 * 
+                * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
                 * [`Writeable::write`]: crate::util::ser::Writeable::write
                 */
-               Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data);
+               Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint channel_id, ChannelMonitor data, MonitorUpdateId update_id);
                /**
-                * Update one channel's data. The provided `ChannelMonitor` has already
-                * applied the given update.
+                * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given
+                * update.
+                * 
+                * Note that on every update, you **must** persist either the [`ChannelMonitorUpdate`] or the
+                * updated monitor itself to disk/backups. See the [`Persist`] trait documentation for more
+                * details.
                 * 
-                * Note that on every update, you **must** persist either the
-                * `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See
-                * the `Persist` trait documentation for more details.
+                * During blockchain synchronization operations, this may be called with no
+                * [`ChannelMonitorUpdate`], in which case the full [`ChannelMonitor`] needs to be persisted.
+                * Note that after the full [`ChannelMonitor`] is persisted any previous
+                * [`ChannelMonitorUpdate`]s which were persisted should be discarded - they can no longer be
+                * applied to the persisted [`ChannelMonitor`] as they were already applied.
                 * 
                 * If an implementer chooses to persist the updates only, they need to make
                 * sure that all the updates are applied to the `ChannelMonitors` *before
@@ -67,32 +86,41 @@ public class Persist extends CommonBase {
                 * them in batches. The size of each monitor grows `O(number of state updates)`
                 * whereas updates are small and `O(1)`.
                 * 
+                * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`],
+                * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`].
+                * 
                 * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`,
                 * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and
                 * [`ChannelMonitorUpdateErr`] for requirements when returning errors.
                 * 
                 * [`Writeable::write`]: crate::util::ser::Writeable::write
+                * 
+                * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None
                 */
-               Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data);
+               Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint channel_id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id);
        }
        private static class LDKPersistHolder { Persist held; }
        public static Persist new_impl(PersistInterface arg) {
                final LDKPersistHolder impl_holder = new LDKPersistHolder();
                impl_holder.held = new Persist(new bindings.LDKPersist() {
-                       @Override public long persist_new_channel(long id, long data) {
-                               OutPoint id_hu_conv = new OutPoint(null, id);
-                               id_hu_conv.ptrs_to.add(this);
-                               ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
-                               Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv);
+                       @Override public long persist_new_channel(long channel_id, long data, long update_id) {
+                               OutPoint channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new OutPoint(null, channel_id); }
+                               channel_id_hu_conv.ptrs_to.add(this);
+                               ChannelMonitor data_hu_conv = null; if (data < 0 || data > 4096) { data_hu_conv = new ChannelMonitor(null, data); }
+                               MonitorUpdateId update_id_hu_conv = null; if (update_id < 0 || update_id > 4096) { update_id_hu_conv = new MonitorUpdateId(null, update_id); }
+                               update_id_hu_conv.ptrs_to.add(this);
+                               Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(channel_id_hu_conv, data_hu_conv, update_id_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
-                       @Override public long update_persisted_channel(long id, long update, long data) {
-                               OutPoint id_hu_conv = new OutPoint(null, id);
-                               id_hu_conv.ptrs_to.add(this);
-                               ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update);
-                               ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
-                               Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv);
+                       @Override public long update_persisted_channel(long channel_id, long update, long data, long update_id) {
+                               OutPoint channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new OutPoint(null, channel_id); }
+                               channel_id_hu_conv.ptrs_to.add(this);
+                               ChannelMonitorUpdate update_hu_conv = null; if (update < 0 || update > 4096) { update_hu_conv = new ChannelMonitorUpdate(null, update); }
+                               ChannelMonitor data_hu_conv = null; if (data < 0 || data > 4096) { data_hu_conv = new ChannelMonitor(null, data); }
+                               MonitorUpdateId update_id_hu_conv = null; if (update_id < 0 || update_id > 4096) { update_id_hu_conv = new MonitorUpdateId(null, update_id); }
+                               update_id_hu_conv.ptrs_to.add(this);
+                               Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(channel_id_hu_conv, update_hu_conv, data_hu_conv, update_id_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
@@ -100,32 +128,43 @@ public class Persist extends CommonBase {
                return impl_holder.held;
        }
        /**
-        * Persist a new channel's data. The data can be stored any way you want, but
-        * the identifier provided by Rust-Lightning is the channel's outpoint (and
-        * it is up to you to maintain a correct mapping between the outpoint and the
-        * stored channel data). Note that you **must** persist every new monitor to
-        * disk. See the `Persist` trait documentation for more details.
+        * Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is
+        * called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup.
+        * 
+        * The data can be stored any way you want, but the identifier provided by LDK is the
+        * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint
+        * and the stored channel data). Note that you **must** persist every new monitor to disk.
+        * 
+        * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`],
+        * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`].
         * 
         * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`
         * and [`ChannelMonitorUpdateErr`] for requirements when returning errors.
         * 
+        * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
         * [`Writeable::write`]: crate::util::ser::Writeable::write
         */
-       public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) {
-               long ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint channel_id, ChannelMonitor data, MonitorUpdateId update_id) {
+               long ret = bindings.Persist_persist_new_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(data);
                return ret_hu_conv;
        }
 
        /**
-        * Update one channel's data. The provided `ChannelMonitor` has already
-        * applied the given update.
+        * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given
+        * update.
         * 
-        * Note that on every update, you **must** persist either the
-        * `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See
-        * the `Persist` trait documentation for more details.
+        * Note that on every update, you **must** persist either the [`ChannelMonitorUpdate`] or the
+        * updated monitor itself to disk/backups. See the [`Persist`] trait documentation for more
+        * details.
+        * 
+        * During blockchain synchronization operations, this may be called with no
+        * [`ChannelMonitorUpdate`], in which case the full [`ChannelMonitor`] needs to be persisted.
+        * Note that after the full [`ChannelMonitor`] is persisted any previous
+        * [`ChannelMonitorUpdate`]s which were persisted should be discarded - they can no longer be
+        * applied to the persisted [`ChannelMonitor`] as they were already applied.
         * 
         * If an implementer chooses to persist the updates only, they need to make
         * sure that all the updates are applied to the `ChannelMonitors` *before
@@ -139,15 +178,20 @@ public class Persist extends CommonBase {
         * them in batches. The size of each monitor grows `O(number of state updates)`
         * whereas updates are small and `O(1)`.
         * 
+        * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`],
+        * if you return [`ChannelMonitorUpdateErr::TemporaryFailure`].
+        * 
         * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`,
         * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and
         * [`ChannelMonitorUpdateErr`] for requirements when returning errors.
         * 
         * [`Writeable::write`]: crate::util::ser::Writeable::write
+        * 
+        * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) {
-               long ret = bindings.Persist_update_persisted_channel(this.ptr, id == null ? 0 : id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint channel_id, @Nullable ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) {
+               long ret = bindings.Persist_update_persisted_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(update);
                this.ptrs_to.add(data);
index 6c17f2fb90a9bf25abb4eea08afd4ecf77a70759..4ef0ce5f7166be7a42b8a237f478e99c69dbcf23 100644 (file)
@@ -56,8 +56,8 @@ public class Ping extends CommonBase {
         */
        public static Ping of(short ponglen_arg, short byteslen_arg) {
                long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Ping ret_hu_conv = new Ping(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -67,8 +67,8 @@ public class Ping extends CommonBase {
         */
        public Ping clone() {
                long ret = bindings.Ping_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Ping ret_hu_conv = new Ping(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Ping(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -86,7 +86,7 @@ public class Ping extends CommonBase {
         */
        public static Result_PingDecodeErrorZ read(byte[] ser) {
                long ret = bindings.Ping_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 0ca9c7ea2e293a80de5a0512225dc390d13d85bd..50fafe464ea05031e6a60aedd10d7cb84f5dfaf4 100644 (file)
@@ -41,8 +41,8 @@ public class Pong extends CommonBase {
         */
        public static Pong of(short byteslen_arg) {
                long ret = bindings.Pong_new(byteslen_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Pong ret_hu_conv = new Pong(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Pong(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -52,8 +52,8 @@ public class Pong extends CommonBase {
         */
        public Pong clone() {
                long ret = bindings.Pong_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Pong ret_hu_conv = new Pong(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Pong(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -71,7 +71,7 @@ public class Pong extends CommonBase {
         */
        public static Result_PongDecodeErrorZ read(byte[] ser) {
                long ret = bindings.Pong_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 81db6083eac193e3f4ab8e970faeab84a8d91197..5c5e22723c907492084b96385480a1116dfe3f22 100644 (file)
@@ -40,8 +40,8 @@ public class PositiveTimestamp extends CommonBase {
         */
        public PositiveTimestamp clone() {
                long ret = bindings.PositiveTimestamp_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PositiveTimestamp ret_hu_conv = new PositiveTimestamp(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class PositiveTimestamp extends CommonBase {
         */
        public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp(long unix_seconds) {
                long ret = bindings.PositiveTimestamp_from_unix_timestamp(unix_seconds);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -65,7 +65,7 @@ public class PositiveTimestamp extends CommonBase {
         */
        public static Result_PositiveTimestampCreationErrorZ from_system_time(long time) {
                long ret = bindings.PositiveTimestamp_from_system_time(time);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2c9931ad04929033d29fa57366d798c280b4ea1e..a74bcc892381ca926249cd915617d546fae0dd36 100644 (file)
@@ -27,8 +27,8 @@ public class PrivateRoute extends CommonBase {
         */
        public PrivateRoute clone() {
                long ret = bindings.PrivateRoute_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PrivateRoute ret_hu_conv = new PrivateRoute(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PrivateRoute ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PrivateRoute(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -57,7 +57,7 @@ public class PrivateRoute extends CommonBase {
         */
        public static Result_PrivateRouteCreationErrorZ of(RouteHint hops) {
                long ret = bindings.PrivateRoute_new(hops == null ? 0 : hops.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,8 +67,8 @@ public class PrivateRoute extends CommonBase {
         */
        public RouteHint into_inner() {
                long ret = bindings.PrivateRoute_into_inner(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHint ret_hu_conv = new RouteHint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                ;
                return ret_hu_conv;
index 97fd5401c380e41c013ce9f8532223124f9ccca8..d249d84b1760dc11fa219a783b1eb8f67b210e6f 100644 (file)
@@ -72,8 +72,8 @@ public class QueryChannelRange extends CommonBase {
         */
        public static QueryChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg) {
                long ret = bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryChannelRange(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -83,8 +83,8 @@ public class QueryChannelRange extends CommonBase {
         */
        public QueryChannelRange clone() {
                long ret = bindings.QueryChannelRange_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               QueryChannelRange ret_hu_conv = new QueryChannelRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               QueryChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryChannelRange(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -110,7 +110,7 @@ public class QueryChannelRange extends CommonBase {
         */
        public static Result_QueryChannelRangeDecodeErrorZ read(byte[] ser) {
                long ret = bindings.QueryChannelRange_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2b31c9b90d8afbf7246b0fbeb703bc7b7144b1f0..2f79a0d8a2f9e1ac4e821b1c7b0f86cb2ec40875 100644 (file)
@@ -53,8 +53,8 @@ public class QueryShortChannelIds extends CommonBase {
         */
        public static QueryShortChannelIds of(byte[] chain_hash_arg, long[] short_channel_ids_arg) {
                long ret = bindings.QueryShortChannelIds_new(chain_hash_arg, short_channel_ids_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               QueryShortChannelIds ret_hu_conv = new QueryShortChannelIds(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryShortChannelIds(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -64,8 +64,8 @@ public class QueryShortChannelIds extends CommonBase {
         */
        public QueryShortChannelIds clone() {
                long ret = bindings.QueryShortChannelIds_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               QueryShortChannelIds ret_hu_conv = new QueryShortChannelIds(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               QueryShortChannelIds ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new QueryShortChannelIds(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -75,7 +75,7 @@ public class QueryShortChannelIds extends CommonBase {
         */
        public static Result_QueryShortChannelIdsDecodeErrorZ read(byte[] ser) {
                long ret = bindings.QueryShortChannelIds_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d89766b70cccfd9ebbcb883cb58fd59b0dc2f98a..4cb9a656d311642b5396d2f572ada59308704b45 100644 (file)
@@ -24,8 +24,8 @@ public class RawDataPart extends CommonBase {
         */
        public PositiveTimestamp get_timestamp() {
                long ret = bindings.RawDataPart_get_timestamp(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PositiveTimestamp ret_hu_conv = new PositiveTimestamp(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -53,8 +53,8 @@ public class RawDataPart extends CommonBase {
         */
        public RawDataPart clone() {
                long ret = bindings.RawDataPart_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RawDataPart ret_hu_conv = new RawDataPart(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RawDataPart ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawDataPart(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 1a6a07d0f6f259c0454465fce433550db0b1fff8..5c4a0327be23277ba8f1e715d6e0f2dbdfdc926c 100644 (file)
@@ -28,8 +28,8 @@ public class RawInvoice extends CommonBase {
         */
        public RawDataPart get_data() {
                long ret = bindings.RawInvoice_get_data(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RawDataPart ret_hu_conv = new RawDataPart(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RawDataPart ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawDataPart(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -57,8 +57,8 @@ public class RawInvoice extends CommonBase {
         */
        public RawInvoice clone() {
                long ret = bindings.RawInvoice_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RawInvoice ret_hu_conv = new RawInvoice(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -77,8 +77,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public Sha256 payment_hash() {
                long ret = bindings.RawInvoice_payment_hash(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Sha256 ret_hu_conv = new Sha256(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -89,8 +89,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public Description description() {
                long ret = bindings.RawInvoice_description(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Description ret_hu_conv = new Description(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Description(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -101,8 +101,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public PayeePubKey payee_pub_key() {
                long ret = bindings.RawInvoice_payee_pub_key(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PayeePubKey ret_hu_conv = new PayeePubKey(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PayeePubKey(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -113,8 +113,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public Sha256 description_hash() {
                long ret = bindings.RawInvoice_description_hash(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Sha256 ret_hu_conv = new Sha256(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -125,8 +125,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public ExpiryTime expiry_time() {
                long ret = bindings.RawInvoice_expiry_time(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ExpiryTime ret_hu_conv = new ExpiryTime(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -137,8 +137,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public MinFinalCltvExpiry min_final_cltv_expiry() {
                long ret = bindings.RawInvoice_min_final_cltv_expiry(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               MinFinalCltvExpiry ret_hu_conv = new MinFinalCltvExpiry(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MinFinalCltvExpiry(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -158,8 +158,8 @@ public class RawInvoice extends CommonBase {
        @Nullable
        public InvoiceFeatures features() {
                long ret = bindings.RawInvoice_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceFeatures ret_hu_conv = new InvoiceFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -169,7 +169,7 @@ public class RawInvoice extends CommonBase {
                PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret.length];
                for (int o = 0; o < ret.length; o++) {
                        long ret_conv_14 = ret[o];
-                       PrivateRoute ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14);
+                       PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14); }
                        ret_conv_14_hu_conv.ptrs_to.add(this);
                        ret_conv_14_arr[o] = ret_conv_14_hu_conv;
                }
@@ -178,7 +178,7 @@ public class RawInvoice extends CommonBase {
 
        public Option_u64Z amount_pico_btc() {
                long ret = bindings.RawInvoice_amount_pico_btc(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 0938058cceeb7004765a3d87579a2e8997192a3e..d95374dae145d04d1284bab846618467ad70cd3c 100644 (file)
@@ -26,7 +26,7 @@ public class ReadOnlyNetworkGraph extends CommonBase {
         */
        public Option_CVec_NetAddressZZ get_addresses(byte[] pubkey) {
                long ret = bindings.ReadOnlyNetworkGraph_get_addresses(this.ptr, pubkey);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_CVec_NetAddressZZ ret_hu_conv = Option_CVec_NetAddressZZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 06cc41f8ef3d9bc0ceb066a1760a1bb291aeba47..4f6db16001a3436e2e9b30c1d41c76b7ba679938 100644 (file)
@@ -97,8 +97,8 @@ public class ReplyChannelRange extends CommonBase {
         */
        public static ReplyChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, boolean sync_complete_arg, long[] short_channel_ids_arg) {
                long ret = bindings.ReplyChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ReplyChannelRange ret_hu_conv = new ReplyChannelRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReplyChannelRange(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -108,8 +108,8 @@ public class ReplyChannelRange extends CommonBase {
         */
        public ReplyChannelRange clone() {
                long ret = bindings.ReplyChannelRange_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ReplyChannelRange ret_hu_conv = new ReplyChannelRange(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ReplyChannelRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReplyChannelRange(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -119,7 +119,7 @@ public class ReplyChannelRange extends CommonBase {
         */
        public static Result_ReplyChannelRangeDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ReplyChannelRange_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index ade43d8db6c4618ddf972ac6c6a7cc9b6b2a3d00..488e7dfe7e566137f12d809379c6b378bbfee468 100644 (file)
@@ -59,8 +59,8 @@ public class ReplyShortChannelIdsEnd extends CommonBase {
         */
        public static ReplyShortChannelIdsEnd of(byte[] chain_hash_arg, boolean full_information_arg) {
                long ret = bindings.ReplyShortChannelIdsEnd_new(chain_hash_arg, full_information_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ReplyShortChannelIdsEnd ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ReplyShortChannelIdsEnd ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -70,8 +70,8 @@ public class ReplyShortChannelIdsEnd extends CommonBase {
         */
        public ReplyShortChannelIdsEnd clone() {
                long ret = bindings.ReplyShortChannelIdsEnd_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ReplyShortChannelIdsEnd ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ReplyShortChannelIdsEnd ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ReplyShortChannelIdsEnd(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -89,7 +89,7 @@ public class ReplyShortChannelIdsEnd extends CommonBase {
         */
        public static Result_ReplyShortChannelIdsEndDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ReplyShortChannelIdsEnd_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5d2b743ea7be98dcc984475122ff171ee1da1136..662a6bd79caa68ce1be72588f7460cc72a808bf4 100644 (file)
@@ -24,7 +24,7 @@ public class Result_AcceptChannelDecodeErrorZ extends CommonBase {
                private Result_AcceptChannelDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_AcceptChannelDecodeErrorZ_get_ok(ptr);
-                       AcceptChannel res_hu_conv = new AcceptChannel(null, res);
+                       AcceptChannel res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new AcceptChannel(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_AcceptChannelDecodeErrorZ extends CommonBase {
                private Result_AcceptChannelDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_AcceptChannelDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_AcceptChannelDecodeErrorZ extends CommonBase {
         */
        public static Result_AcceptChannelDecodeErrorZ ok(AcceptChannel o) {
                long ret = bindings.CResult_AcceptChannelDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_AcceptChannelDecodeErrorZ extends CommonBase {
         */
        public static Result_AcceptChannelDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_AcceptChannelDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_AcceptChannelDecodeErrorZ extends CommonBase {
         */
        public Result_AcceptChannelDecodeErrorZ clone() {
                long ret = bindings.CResult_AcceptChannelDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 66205d0a061c4b5efe71c677172294258edc7ac1..d711f7fa0bfe31365bbd706d1bc1f72c307fe05f 100644 (file)
@@ -24,7 +24,7 @@ public class Result_AnnouncementSignaturesDecodeErrorZ extends CommonBase {
                private Result_AnnouncementSignaturesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(ptr);
-                       AnnouncementSignatures res_hu_conv = new AnnouncementSignatures(null, res);
+                       AnnouncementSignatures res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new AnnouncementSignatures(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_AnnouncementSignaturesDecodeErrorZ extends CommonBase {
                private Result_AnnouncementSignaturesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_AnnouncementSignaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_AnnouncementSignaturesDecodeErrorZ ok(AnnouncementSignatures o) {
                long ret = bindings.CResult_AnnouncementSignaturesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AnnouncementSignaturesDecodeErrorZ ret_hu_conv = Result_AnnouncementSignaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_AnnouncementSignaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_AnnouncementSignaturesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_AnnouncementSignaturesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AnnouncementSignaturesDecodeErrorZ ret_hu_conv = Result_AnnouncementSignaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_AnnouncementSignaturesDecodeErrorZ extends CommonBase {
         */
        public Result_AnnouncementSignaturesDecodeErrorZ clone() {
                long ret = bindings.CResult_AnnouncementSignaturesDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_AnnouncementSignaturesDecodeErrorZ ret_hu_conv = Result_AnnouncementSignaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 7a8643899610de3dddaabe802ed9644748370c33..6ae3ac955e0661102ab7832c58ebf56b0c3ca170 100644 (file)
@@ -24,7 +24,7 @@ public class Result_BuiltCommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_BuiltCommitmentTransactionDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(ptr);
-                       BuiltCommitmentTransaction res_hu_conv = new BuiltCommitmentTransaction(null, res);
+                       BuiltCommitmentTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new BuiltCommitmentTransaction(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_BuiltCommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_BuiltCommitmentTransactionDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_BuiltCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_BuiltCommitmentTransactionDecodeErrorZ ok(BuiltCommitmentTransaction o) {
                long ret = bindings.CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_BuiltCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_BuiltCommitmentTransactionDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_BuiltCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public Result_BuiltCommitmentTransactionDecodeErrorZ clone() {
                long ret = bindings.CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a81e27748af4d25cfe9daa7fcf1380744286ee93..2a46ea22125d38db43cd4c3a3875d49383a60135 100644 (file)
@@ -35,7 +35,7 @@ public class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ extends CommonB
                private Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ extends CommonB
         */
        public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ok(TwoTuple_BlockHashChannelManagerZ o) {
                long ret = bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ extends CommonB
         */
        public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 85ba9b8c89502f58e3137e9ae4439530d0050eb1..19b37c50a1a6dd2a1a66bcacc67e3c5ccfaa0c76 100644 (file)
@@ -35,7 +35,7 @@ public class Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ extends CommonB
                private Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ extends CommonB
         */
        public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ok(TwoTuple_BlockHashChannelMonitorZ o) {
                long ret = bindings.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ extends CommonB
         */
        public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ extends CommonB
         */
        public Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ clone() {
                long ret = bindings.CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 3e880b174040fbd919c2a94d8c203113be2b18c3..eedd7532e76da6f3e3e600cd160545dd4d2588cf 100644 (file)
@@ -46,7 +46,7 @@ public class Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ extends Com
         */
        public static Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ok(TwoTuple_PaymentHashPaymentIdZ o) {
                long ret = bindings.CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ extends Com
         */
        public static Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ err(PaymentSendFailure e) {
                long ret = bindings.CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ extends Com
         */
        public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ clone() {
                long ret = bindings.CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 43d692b43d50f8e972c01f7943cd56de4a8be5c6..1cd75cd94dc47e0d963973a4d6ef18bd011388c4 100644 (file)
@@ -41,7 +41,7 @@ public class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ extends CommonBase {
         */
        public static Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ok(TwoTuple_SignatureCVec_SignatureZZ o) {
                long ret = bindings.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ extends CommonBase {
         */
        public static Result_C2Tuple_SignatureCVec_SignatureZZNoneZ err() {
                long ret = bindings.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ extends CommonBase {
         */
        public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ clone() {
                long ret = bindings.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5b514a9b6830492eb9c5206fee98ae5d12ea1bbc..fed124a664b74d674715a558193f6a405c239f46 100644 (file)
@@ -35,7 +35,7 @@ public class Result_COption_TypeZDecodeErrorZ extends CommonBase {
                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);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_COption_TypeZDecodeErrorZ extends CommonBase {
         */
        public static Result_COption_TypeZDecodeErrorZ ok(Option_TypeZ o) {
                long ret = bindings.CResult_COption_TypeZDecodeErrorZ_ok(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_COption_TypeZDecodeErrorZ extends CommonBase {
         */
        public static Result_COption_TypeZDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_COption_TypeZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_COption_TypeZDecodeErrorZ extends CommonBase {
         */
        public Result_COption_TypeZDecodeErrorZ clone() {
                long ret = bindings.CResult_COption_TypeZDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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_CResult_NetAddressu8ZDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_CResult_NetAddressu8ZDecodeErrorZ.java
deleted file mode 100644 (file)
index c88d61f..0000000
+++ /dev/null
@@ -1,74 +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;
-
-public class Result_CResult_NetAddressu8ZDecodeErrorZ extends CommonBase {
-       private Result_CResult_NetAddressu8ZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_free(ptr); } super.finalize();
-       }
-
-       static Result_CResult_NetAddressu8ZDecodeErrorZ constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(ptr)) {
-                       return new Result_CResult_NetAddressu8ZDecodeErrorZ_OK(null, ptr);
-               } else {
-                       return new Result_CResult_NetAddressu8ZDecodeErrorZ_Err(null, ptr);
-               }
-       }
-       public static final class Result_CResult_NetAddressu8ZDecodeErrorZ_OK extends Result_CResult_NetAddressu8ZDecodeErrorZ {
-               public final Result_NetAddressu8Z res;
-               private Result_CResult_NetAddressu8ZDecodeErrorZ_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       long res = bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(ptr);
-                       Result_NetAddressu8Z res_hu_conv = Result_NetAddressu8Z.constr_from_ptr(res);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_CResult_NetAddressu8ZDecodeErrorZ_Err extends Result_CResult_NetAddressu8ZDecodeErrorZ {
-               public final DecodeError err;
-               private Result_CResult_NetAddressu8ZDecodeErrorZ_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       long err = bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ in the success state.
-        */
-       public static Result_CResult_NetAddressu8ZDecodeErrorZ ok(Result_NetAddressu8Z o) {
-               long ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o != null ? o.ptr : 0);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the error state.
-        */
-       public static Result_CResult_NetAddressu8ZDecodeErrorZ err(DecodeError e) {
-               long ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig`
-        * but with all dynamically-allocated buffers duplicated in new buffers.
-        */
-       public Result_CResult_NetAddressu8ZDecodeErrorZ clone() {
-               long ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
index bfab1ceb643c65917841820cf9ed14f371889144..a4c38586ea3a50f2da087ccba60c1166082df91a 100644 (file)
@@ -48,7 +48,7 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ extends CommonB
         */
        public static Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ok(TwoTuple_BlockHashChannelMonitorZ[] o) {
                long ret = bindings.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o != null ? Arrays.stream(o).mapToLong(o_conv_35 -> o_conv_35 != null ? o_conv_35.ptr : 0).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -58,7 +58,7 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ extends CommonB
         */
        public static Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ err(org.ldk.enums.IOError e) {
                long ret = bindings.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -69,7 +69,7 @@ public class Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ extends CommonB
         */
        public Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ clone() {
                long ret = bindings.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 66f0e94483ba819a99666d6dcb22e7392a5c3c8f..be1685e3fe62832d1841d1dd504894424e15d6df 100644 (file)
@@ -38,7 +38,7 @@ public class Result_CVec_CVec_u8ZZNoneZ extends CommonBase {
         */
        public static Result_CVec_CVec_u8ZZNoneZ ok(byte[][] o) {
                long ret = bindings.CResult_CVec_CVec_u8ZZNoneZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_CVec_CVec_u8ZZNoneZ extends CommonBase {
         */
        public static Result_CVec_CVec_u8ZZNoneZ err() {
                long ret = bindings.CResult_CVec_CVec_u8ZZNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_CVec_CVec_u8ZZNoneZ extends CommonBase {
         */
        public Result_CVec_CVec_u8ZZNoneZ clone() {
                long ret = bindings.CResult_CVec_CVec_u8ZZNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5a84aee357518b70f6fc3379adf44f362753d1ed..335a2d7376aacb39f8041d7f830b41f7273fb62d 100644 (file)
@@ -38,7 +38,7 @@ public class Result_CVec_SignatureZNoneZ extends CommonBase {
         */
        public static Result_CVec_SignatureZNoneZ ok(byte[][] o) {
                long ret = bindings.CResult_CVec_SignatureZNoneZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_CVec_SignatureZNoneZ extends CommonBase {
         */
        public static Result_CVec_SignatureZNoneZ err() {
                long ret = bindings.CResult_CVec_SignatureZNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_CVec_SignatureZNoneZ extends CommonBase {
         */
        public Result_CVec_SignatureZNoneZ clone() {
                long ret = bindings.CResult_CVec_SignatureZNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index fa201fcf5be65e49426f6b67ea89f8db708a4e63..b85496661c4cc20149058952067ad089a1b68bb9 100644 (file)
@@ -32,7 +32,7 @@ public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase {
                private Result_CVec_u8ZPeerHandleErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(ptr);
-                       PeerHandleError err_hu_conv = new PeerHandleError(null, err);
+                       PeerHandleError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new PeerHandleError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase {
         */
        public static Result_CVec_u8ZPeerHandleErrorZ ok(byte[] o) {
                long ret = bindings.CResult_CVec_u8ZPeerHandleErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase {
         */
        public static Result_CVec_u8ZPeerHandleErrorZ err(PeerHandleError e) {
                long ret = bindings.CResult_CVec_u8ZPeerHandleErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase {
         */
        public Result_CVec_u8ZPeerHandleErrorZ clone() {
                long ret = bindings.CResult_CVec_u8ZPeerHandleErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index bbdef01ef013f3a90e65bd64f0fd25c633cbb56d..9cc0cb296b3c7c4989f3de56c208d6837f35ef55 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelAnnouncementDecodeErrorZ extends CommonBase {
                private Result_ChannelAnnouncementDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(ptr);
-                       ChannelAnnouncement res_hu_conv = new ChannelAnnouncement(null, res);
+                       ChannelAnnouncement res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelAnnouncement(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelAnnouncementDecodeErrorZ extends CommonBase {
                private Result_ChannelAnnouncementDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelAnnouncementDecodeErrorZ ok(ChannelAnnouncement o) {
                long ret = bindings.CResult_ChannelAnnouncementDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelAnnouncementDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelAnnouncementDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelAnnouncementDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelAnnouncementDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c999766158871f1e255bc303a9ac16a2fc63b317..005d53de433253ebb8c29e79808c031e15b14df6 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelConfigDecodeErrorZ extends CommonBase {
                private Result_ChannelConfigDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelConfigDecodeErrorZ_get_ok(ptr);
-                       ChannelConfig res_hu_conv = new ChannelConfig(null, res);
+                       ChannelConfig res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelConfig(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelConfigDecodeErrorZ extends CommonBase {
                private Result_ChannelConfigDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelConfigDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelConfigDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelConfigDecodeErrorZ ok(ChannelConfig o) {
                long ret = bindings.CResult_ChannelConfigDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelConfigDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelConfigDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelConfigDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelConfigDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelConfigDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelConfigDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5041048b06e644f55a485d2327bc922c4110d72d..1253a8d5a0a0070b189be786e203150f2b67d2ad 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelFeaturesDecodeErrorZ extends CommonBase {
                private Result_ChannelFeaturesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(ptr);
-                       ChannelFeatures res_hu_conv = new ChannelFeatures(null, res);
+                       ChannelFeatures res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelFeatures(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelFeaturesDecodeErrorZ extends CommonBase {
                private Result_ChannelFeaturesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelFeaturesDecodeErrorZ ok(ChannelFeatures o) {
                long ret = bindings.CResult_ChannelFeaturesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelFeaturesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelFeaturesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b88b56f0da6d5d2181063a2d8836cb5e8f965819..f0d5078cb710e0c80e01dcb69b0c7708cb22f50d 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelInfoDecodeErrorZ extends CommonBase {
                private Result_ChannelInfoDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelInfoDecodeErrorZ_get_ok(ptr);
-                       ChannelInfo res_hu_conv = new ChannelInfo(null, res);
+                       ChannelInfo res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelInfo(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelInfoDecodeErrorZ extends CommonBase {
                private Result_ChannelInfoDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelInfoDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelInfoDecodeErrorZ ok(ChannelInfo o) {
                long ret = bindings.CResult_ChannelInfoDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelInfoDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelInfoDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelInfoDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelInfoDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelInfoDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5d89780a514b49da4e4ce9569c44789233bf91af..2430db5715946a94d553825e2729aab037a87f34 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelMonitorUpdateDecodeErrorZ extends CommonBase {
                private Result_ChannelMonitorUpdateDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(ptr);
-                       ChannelMonitorUpdate res_hu_conv = new ChannelMonitorUpdate(null, res);
+                       ChannelMonitorUpdate res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelMonitorUpdate(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelMonitorUpdateDecodeErrorZ extends CommonBase {
                private Result_ChannelMonitorUpdateDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelMonitorUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelMonitorUpdateDecodeErrorZ ok(ChannelMonitorUpdate o) {
                long ret = bindings.CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelMonitorUpdateDecodeErrorZ ret_hu_conv = Result_ChannelMonitorUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelMonitorUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelMonitorUpdateDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelMonitorUpdateDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelMonitorUpdateDecodeErrorZ ret_hu_conv = Result_ChannelMonitorUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelMonitorUpdateDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelMonitorUpdateDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelMonitorUpdateDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelMonitorUpdateDecodeErrorZ ret_hu_conv = Result_ChannelMonitorUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b23524e887d219cb0ef9631dae351b0a01605a19..8a9d5b80f435d987880e59d3929b48cb88574c10 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelPublicKeysDecodeErrorZ extends CommonBase {
                private Result_ChannelPublicKeysDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(ptr);
-                       ChannelPublicKeys res_hu_conv = new ChannelPublicKeys(null, res);
+                       ChannelPublicKeys res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelPublicKeys(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelPublicKeysDecodeErrorZ extends CommonBase {
                private Result_ChannelPublicKeysDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelPublicKeysDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelPublicKeysDecodeErrorZ ok(ChannelPublicKeys o) {
                long ret = bindings.CResult_ChannelPublicKeysDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelPublicKeysDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelPublicKeysDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelPublicKeysDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelPublicKeysDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelPublicKeysDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelPublicKeysDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 7d9633aa80c72f0e3327a1b664dc71937f07ad91..ea90e563cde9ab6e56d43b17c9aad70cc7f17daa 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelReestablishDecodeErrorZ extends CommonBase {
                private Result_ChannelReestablishDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(ptr);
-                       ChannelReestablish res_hu_conv = new ChannelReestablish(null, res);
+                       ChannelReestablish res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelReestablish(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelReestablishDecodeErrorZ extends CommonBase {
                private Result_ChannelReestablishDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelReestablishDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelReestablishDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelReestablishDecodeErrorZ ok(ChannelReestablish o) {
                long ret = bindings.CResult_ChannelReestablishDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelReestablishDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelReestablishDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelReestablishDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelReestablishDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelReestablishDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelReestablishDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelReestablishDecodeErrorZ ret_hu_conv = Result_ChannelReestablishDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 78c72872110afd287770affb25642d6367e6c971..6911dfe8cbe00134da33603b229ed380a6736bce 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelTransactionParametersDecodeErrorZ extends CommonBase
                private Result_ChannelTransactionParametersDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(ptr);
-                       ChannelTransactionParameters res_hu_conv = new ChannelTransactionParameters(null, res);
+                       ChannelTransactionParameters res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelTransactionParameters(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelTransactionParametersDecodeErrorZ extends CommonBase
                private Result_ChannelTransactionParametersDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelTransactionParametersDecodeErrorZ extends CommonBase
         */
        public static Result_ChannelTransactionParametersDecodeErrorZ ok(ChannelTransactionParameters o) {
                long ret = bindings.CResult_ChannelTransactionParametersDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelTransactionParametersDecodeErrorZ extends CommonBase
         */
        public static Result_ChannelTransactionParametersDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelTransactionParametersDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelTransactionParametersDecodeErrorZ extends CommonBase
         */
        public Result_ChannelTransactionParametersDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelTransactionParametersDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_ChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 43eec2d2d60155d0816c283b8094a8799b50639c..bf791411dd2af826e8f5ec8eeb9ae5899abe6bc1 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ChannelUpdateDecodeErrorZ extends CommonBase {
                private Result_ChannelUpdateDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(ptr);
-                       ChannelUpdate res_hu_conv = new ChannelUpdate(null, res);
+                       ChannelUpdate res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ChannelUpdate(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ChannelUpdateDecodeErrorZ extends CommonBase {
                private Result_ChannelUpdateDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ChannelUpdateDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelUpdateDecodeErrorZ ok(ChannelUpdate o) {
                long ret = bindings.CResult_ChannelUpdateDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_ChannelUpdateDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ChannelUpdateDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public Result_ChannelUpdateDecodeErrorZ clone() {
                long ret = bindings.CResult_ChannelUpdateDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index fdc1f01eb68f732f3b50b1e68be6effaad6f95dd..f681c9630d48a8af3a4d6ab327855e33b2f00782 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ClosingSignedDecodeErrorZ extends CommonBase {
                private Result_ClosingSignedDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ClosingSignedDecodeErrorZ_get_ok(ptr);
-                       ClosingSigned res_hu_conv = new ClosingSigned(null, res);
+                       ClosingSigned res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ClosingSigned(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ClosingSignedDecodeErrorZ extends CommonBase {
                private Result_ClosingSignedDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ClosingSignedDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ClosingSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_ClosingSignedDecodeErrorZ ok(ClosingSigned o) {
                long ret = bindings.CResult_ClosingSignedDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ClosingSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_ClosingSignedDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ClosingSignedDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ClosingSignedDecodeErrorZ extends CommonBase {
         */
        public Result_ClosingSignedDecodeErrorZ clone() {
                long ret = bindings.CResult_ClosingSignedDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 4dd36811efcd5946e76cd99cb9c89076d9ca18a7..deb8156599c5b146625691159374892fc12579fb 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ClosingSignedFeeRangeDecodeErrorZ extends CommonBase {
                private Result_ClosingSignedFeeRangeDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(ptr);
-                       ClosingSignedFeeRange res_hu_conv = new ClosingSignedFeeRange(null, res);
+                       ClosingSignedFeeRange res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ClosingSignedFeeRange(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ClosingSignedFeeRangeDecodeErrorZ extends CommonBase {
                private Result_ClosingSignedFeeRangeDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ClosingSignedFeeRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_ClosingSignedFeeRangeDecodeErrorZ ok(ClosingSignedFeeRange o) {
                long ret = bindings.CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedFeeRangeDecodeErrorZ ret_hu_conv = Result_ClosingSignedFeeRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ClosingSignedFeeRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_ClosingSignedFeeRangeDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedFeeRangeDecodeErrorZ ret_hu_conv = Result_ClosingSignedFeeRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ClosingSignedFeeRangeDecodeErrorZ extends CommonBase {
         */
        public Result_ClosingSignedFeeRangeDecodeErrorZ clone() {
                long ret = bindings.CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ClosingSignedFeeRangeDecodeErrorZ ret_hu_conv = Result_ClosingSignedFeeRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index f53fbef806fd14a007365c92a521705a9bef40d4..547e7530c0095066f5aff4db06f5e67009f923ec 100644 (file)
@@ -24,7 +24,7 @@ public class Result_CommitmentSignedDecodeErrorZ extends CommonBase {
                private Result_CommitmentSignedDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(ptr);
-                       CommitmentSigned res_hu_conv = new CommitmentSigned(null, res);
+                       CommitmentSigned res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new CommitmentSigned(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_CommitmentSignedDecodeErrorZ extends CommonBase {
                private Result_CommitmentSignedDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_CommitmentSignedDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_CommitmentSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_CommitmentSignedDecodeErrorZ ok(CommitmentSigned o) {
                long ret = bindings.CResult_CommitmentSignedDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_CommitmentSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_CommitmentSignedDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_CommitmentSignedDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_CommitmentSignedDecodeErrorZ extends CommonBase {
         */
        public Result_CommitmentSignedDecodeErrorZ clone() {
                long ret = bindings.CResult_CommitmentSignedDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentSignedDecodeErrorZ ret_hu_conv = Result_CommitmentSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index f334988973758f5a37bbc1cca03e0413941a1c01..4048b00c44a9ba88b790e23db2807948dd607a02 100644 (file)
@@ -24,7 +24,7 @@ public class Result_CommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_CommitmentTransactionDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(ptr);
-                       CommitmentTransaction res_hu_conv = new CommitmentTransaction(null, res);
+                       CommitmentTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new CommitmentTransaction(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_CommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_CommitmentTransactionDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_CommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_CommitmentTransactionDecodeErrorZ ok(CommitmentTransaction o) {
                long ret = bindings.CResult_CommitmentTransactionDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_CommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_CommitmentTransactionDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_CommitmentTransactionDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_CommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public Result_CommitmentTransactionDecodeErrorZ clone() {
                long ret = bindings.CResult_CommitmentTransactionDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 54be3091359b885ea0a52fa60ee2b66953e6625d..33b5b2e023b96b238105d4295950efabc645d85b 100644 (file)
@@ -24,7 +24,7 @@ public class Result_CounterpartyChannelTransactionParametersDecodeErrorZ extends
                private Result_CounterpartyChannelTransactionParametersDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(ptr);
-                       CounterpartyChannelTransactionParameters res_hu_conv = new CounterpartyChannelTransactionParameters(null, res);
+                       CounterpartyChannelTransactionParameters res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new CounterpartyChannelTransactionParameters(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_CounterpartyChannelTransactionParametersDecodeErrorZ extends
                private Result_CounterpartyChannelTransactionParametersDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_CounterpartyChannelTransactionParametersDecodeErrorZ extends
         */
        public static Result_CounterpartyChannelTransactionParametersDecodeErrorZ ok(CounterpartyChannelTransactionParameters o) {
                long ret = bindings.CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CounterpartyChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_CounterpartyChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_CounterpartyChannelTransactionParametersDecodeErrorZ extends
         */
        public static Result_CounterpartyChannelTransactionParametersDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CounterpartyChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_CounterpartyChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_CounterpartyChannelTransactionParametersDecodeErrorZ extends
         */
        public Result_CounterpartyChannelTransactionParametersDecodeErrorZ clone() {
                long ret = bindings.CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CounterpartyChannelTransactionParametersDecodeErrorZ ret_hu_conv = Result_CounterpartyChannelTransactionParametersDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 01966966949987053765a886a115904666e87630..04a3630cc32e3890212c781c89d8eb3361023970 100644 (file)
@@ -24,7 +24,7 @@ public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ extends CommonBas
                private Result_DelayedPaymentOutputDescriptorDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(ptr);
-                       DelayedPaymentOutputDescriptor res_hu_conv = new DelayedPaymentOutputDescriptor(null, res);
+                       DelayedPaymentOutputDescriptor res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new DelayedPaymentOutputDescriptor(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ extends CommonBas
                private Result_DelayedPaymentOutputDescriptorDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ extends CommonBas
         */
        public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ ok(DelayedPaymentOutputDescriptor o) {
                long ret = bindings.CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ extends CommonBas
         */
        public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_DelayedPaymentOutputDescriptorDecodeErrorZ extends CommonBas
         */
        public Result_DelayedPaymentOutputDescriptorDecodeErrorZ clone() {
                long ret = bindings.CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d5e60bc2b0ba4de9a13216f71f834ff600ef9f6a..aa751e7ad3f081b264121f8a9a9219ee9065363a 100644 (file)
@@ -24,7 +24,7 @@ public class Result_DescriptionCreationErrorZ extends CommonBase {
                private Result_DescriptionCreationErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_DescriptionCreationErrorZ_get_ok(ptr);
-                       Description res_hu_conv = new Description(null, res);
+                       Description res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Description(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_DescriptionCreationErrorZ extends CommonBase {
         */
        public static Result_DescriptionCreationErrorZ ok(Description o) {
                long ret = bindings.CResult_DescriptionCreationErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_DescriptionCreationErrorZ extends CommonBase {
         */
        public static Result_DescriptionCreationErrorZ err(org.ldk.enums.CreationError e) {
                long ret = bindings.CResult_DescriptionCreationErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_DescriptionCreationErrorZ extends CommonBase {
         */
        public Result_DescriptionCreationErrorZ clone() {
                long ret = bindings.CResult_DescriptionCreationErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DescriptionCreationErrorZ ret_hu_conv = Result_DescriptionCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 27b026bf45373da92439a9218dec2b72c8b8ca31..f9bd1718667313c97722966853ac0c2172866b43 100644 (file)
@@ -24,7 +24,7 @@ public class Result_DirectionalChannelInfoDecodeErrorZ extends CommonBase {
                private Result_DirectionalChannelInfoDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(ptr);
-                       DirectionalChannelInfo res_hu_conv = new DirectionalChannelInfo(null, res);
+                       DirectionalChannelInfo res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new DirectionalChannelInfo(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_DirectionalChannelInfoDecodeErrorZ extends CommonBase {
                private Result_DirectionalChannelInfoDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_DirectionalChannelInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_DirectionalChannelInfoDecodeErrorZ ok(DirectionalChannelInfo o) {
                long ret = bindings.CResult_DirectionalChannelInfoDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_DirectionalChannelInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_DirectionalChannelInfoDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_DirectionalChannelInfoDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_DirectionalChannelInfoDecodeErrorZ extends CommonBase {
         */
        public Result_DirectionalChannelInfoDecodeErrorZ clone() {
                long ret = bindings.CResult_DirectionalChannelInfoDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 31f44f2506ecc11c49e3a38ef947e979b1dc5f69..41212aa787ce640365dad194247b6697cc7f3f5e 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ErrorMessageDecodeErrorZ extends CommonBase {
                private Result_ErrorMessageDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ErrorMessageDecodeErrorZ_get_ok(ptr);
-                       ErrorMessage res_hu_conv = new ErrorMessage(null, res);
+                       ErrorMessage res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ErrorMessage(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ErrorMessageDecodeErrorZ extends CommonBase {
                private Result_ErrorMessageDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ErrorMessageDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ErrorMessageDecodeErrorZ extends CommonBase {
         */
        public static Result_ErrorMessageDecodeErrorZ ok(ErrorMessage o) {
                long ret = bindings.CResult_ErrorMessageDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ErrorMessageDecodeErrorZ extends CommonBase {
         */
        public static Result_ErrorMessageDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ErrorMessageDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ErrorMessageDecodeErrorZ extends CommonBase {
         */
        public Result_ErrorMessageDecodeErrorZ clone() {
                long ret = bindings.CResult_ErrorMessageDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2b274855e8bf52a22a3cec1efc0dab94af5efc1a..23c690c32a15afa43d06d2a8508776f103e54a13 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ExpiryTimeCreationErrorZ extends CommonBase {
                private Result_ExpiryTimeCreationErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ExpiryTimeCreationErrorZ_get_ok(ptr);
-                       ExpiryTime res_hu_conv = new ExpiryTime(null, res);
+                       ExpiryTime res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ExpiryTime(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_ExpiryTimeCreationErrorZ extends CommonBase {
         */
        public static Result_ExpiryTimeCreationErrorZ ok(ExpiryTime o) {
                long ret = bindings.CResult_ExpiryTimeCreationErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_ExpiryTimeCreationErrorZ extends CommonBase {
         */
        public static Result_ExpiryTimeCreationErrorZ err(org.ldk.enums.CreationError e) {
                long ret = bindings.CResult_ExpiryTimeCreationErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_ExpiryTimeCreationErrorZ extends CommonBase {
         */
        public Result_ExpiryTimeCreationErrorZ clone() {
                long ret = bindings.CResult_ExpiryTimeCreationErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ExpiryTimeCreationErrorZ ret_hu_conv = Result_ExpiryTimeCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index f74933c038092aa7023c028d672ce783b098a4be..719a7cea8ab8094016a8a19a3b38ef20e3e4a142 100644 (file)
@@ -24,7 +24,7 @@ public class Result_FundingCreatedDecodeErrorZ extends CommonBase {
                private Result_FundingCreatedDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_FundingCreatedDecodeErrorZ_get_ok(ptr);
-                       FundingCreated res_hu_conv = new FundingCreated(null, res);
+                       FundingCreated res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new FundingCreated(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_FundingCreatedDecodeErrorZ extends CommonBase {
                private Result_FundingCreatedDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_FundingCreatedDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_FundingCreatedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingCreatedDecodeErrorZ ok(FundingCreated o) {
                long ret = bindings.CResult_FundingCreatedDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_FundingCreatedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingCreatedDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_FundingCreatedDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_FundingCreatedDecodeErrorZ extends CommonBase {
         */
        public Result_FundingCreatedDecodeErrorZ clone() {
                long ret = bindings.CResult_FundingCreatedDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 4fe75539b74826788e72e3bb6d00af463db57f2e..44c159df0bb2037ddb8efa4ef597558ab850947f 100644 (file)
@@ -24,7 +24,7 @@ public class Result_FundingLockedDecodeErrorZ extends CommonBase {
                private Result_FundingLockedDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_FundingLockedDecodeErrorZ_get_ok(ptr);
-                       FundingLocked res_hu_conv = new FundingLocked(null, res);
+                       FundingLocked res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new FundingLocked(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_FundingLockedDecodeErrorZ extends CommonBase {
                private Result_FundingLockedDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_FundingLockedDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_FundingLockedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingLockedDecodeErrorZ ok(FundingLocked o) {
                long ret = bindings.CResult_FundingLockedDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingLockedDecodeErrorZ ret_hu_conv = Result_FundingLockedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_FundingLockedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingLockedDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_FundingLockedDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingLockedDecodeErrorZ ret_hu_conv = Result_FundingLockedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_FundingLockedDecodeErrorZ extends CommonBase {
         */
        public Result_FundingLockedDecodeErrorZ clone() {
                long ret = bindings.CResult_FundingLockedDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingLockedDecodeErrorZ ret_hu_conv = Result_FundingLockedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 39fbb1db33243d6b59863776157442de49cfb6e2..7ac9f23d27ea32c09d2fe096773fa7264ab8ed27 100644 (file)
@@ -24,7 +24,7 @@ public class Result_FundingSignedDecodeErrorZ extends CommonBase {
                private Result_FundingSignedDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_FundingSignedDecodeErrorZ_get_ok(ptr);
-                       FundingSigned res_hu_conv = new FundingSigned(null, res);
+                       FundingSigned res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new FundingSigned(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_FundingSignedDecodeErrorZ extends CommonBase {
                private Result_FundingSignedDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_FundingSignedDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_FundingSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingSignedDecodeErrorZ ok(FundingSigned o) {
                long ret = bindings.CResult_FundingSignedDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_FundingSignedDecodeErrorZ extends CommonBase {
         */
        public static Result_FundingSignedDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_FundingSignedDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_FundingSignedDecodeErrorZ extends CommonBase {
         */
        public Result_FundingSignedDecodeErrorZ clone() {
                long ret = bindings.CResult_FundingSignedDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 73899231c418dbca8cd546ddec7edc0487b364c9..ec51d5554e1729bacad6ba1ab7bc8722b8b75779 100644 (file)
@@ -24,7 +24,7 @@ public class Result_GossipTimestampFilterDecodeErrorZ extends CommonBase {
                private Result_GossipTimestampFilterDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(ptr);
-                       GossipTimestampFilter res_hu_conv = new GossipTimestampFilter(null, res);
+                       GossipTimestampFilter res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new GossipTimestampFilter(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_GossipTimestampFilterDecodeErrorZ extends CommonBase {
                private Result_GossipTimestampFilterDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_GossipTimestampFilterDecodeErrorZ extends CommonBase {
         */
        public static Result_GossipTimestampFilterDecodeErrorZ ok(GossipTimestampFilter o) {
                long ret = bindings.CResult_GossipTimestampFilterDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_GossipTimestampFilterDecodeErrorZ extends CommonBase {
         */
        public static Result_GossipTimestampFilterDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_GossipTimestampFilterDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_GossipTimestampFilterDecodeErrorZ extends CommonBase {
         */
        public Result_GossipTimestampFilterDecodeErrorZ clone() {
                long ret = bindings.CResult_GossipTimestampFilterDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5e913b5d9b473123e2712614427157bf47c827f0..d568dcc926842572a84cccc41c82598b1a61209c 100644 (file)
@@ -24,7 +24,7 @@ public class Result_HTLCOutputInCommitmentDecodeErrorZ extends CommonBase {
                private Result_HTLCOutputInCommitmentDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(ptr);
-                       HTLCOutputInCommitment res_hu_conv = new HTLCOutputInCommitment(null, res);
+                       HTLCOutputInCommitment res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new HTLCOutputInCommitment(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_HTLCOutputInCommitmentDecodeErrorZ extends CommonBase {
                private Result_HTLCOutputInCommitmentDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_HTLCOutputInCommitmentDecodeErrorZ extends CommonBase {
         */
        public static Result_HTLCOutputInCommitmentDecodeErrorZ ok(HTLCOutputInCommitment o) {
                long ret = bindings.CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_HTLCOutputInCommitmentDecodeErrorZ extends CommonBase {
         */
        public static Result_HTLCOutputInCommitmentDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_HTLCOutputInCommitmentDecodeErrorZ extends CommonBase {
         */
        public Result_HTLCOutputInCommitmentDecodeErrorZ clone() {
                long ret = bindings.CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCOutputInCommitmentDecodeErrorZ ret_hu_conv = Result_HTLCOutputInCommitmentDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d0c98eb7eac9dfd7b2d2dea259886504d88db78d..c4517ded946eb3cd84d69effddfe831b0dc4e79a 100644 (file)
@@ -24,7 +24,7 @@ public class Result_HTLCUpdateDecodeErrorZ extends CommonBase {
                private Result_HTLCUpdateDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(ptr);
-                       HTLCUpdate res_hu_conv = new HTLCUpdate(null, res);
+                       HTLCUpdate res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new HTLCUpdate(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_HTLCUpdateDecodeErrorZ extends CommonBase {
                private Result_HTLCUpdateDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_HTLCUpdateDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_HTLCUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_HTLCUpdateDecodeErrorZ ok(HTLCUpdate o) {
                long ret = bindings.CResult_HTLCUpdateDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCUpdateDecodeErrorZ ret_hu_conv = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_HTLCUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_HTLCUpdateDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_HTLCUpdateDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCUpdateDecodeErrorZ ret_hu_conv = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_HTLCUpdateDecodeErrorZ extends CommonBase {
         */
        public Result_HTLCUpdateDecodeErrorZ clone() {
                long ret = bindings.CResult_HTLCUpdateDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HTLCUpdateDecodeErrorZ ret_hu_conv = Result_HTLCUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b0bb4e28af0f7e02f22e8b120963280566b84c7d..83d0205f2ff2d94ef4f16af9d5cfd934a0c87ed0 100644 (file)
@@ -24,7 +24,7 @@ public class Result_HolderCommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_HolderCommitmentTransactionDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(ptr);
-                       HolderCommitmentTransaction res_hu_conv = new HolderCommitmentTransaction(null, res);
+                       HolderCommitmentTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new HolderCommitmentTransaction(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_HolderCommitmentTransactionDecodeErrorZ extends CommonBase {
                private Result_HolderCommitmentTransactionDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_HolderCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_HolderCommitmentTransactionDecodeErrorZ ok(HolderCommitmentTransaction o) {
                long ret = bindings.CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_HolderCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public static Result_HolderCommitmentTransactionDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_HolderCommitmentTransactionDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_HolderCommitmentTransactionDecodeErrorZ extends CommonBase {
         */
        public Result_HolderCommitmentTransactionDecodeErrorZ clone() {
                long ret = bindings.CResult_HolderCommitmentTransactionDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 3ac925dadbf193bc70669c3aa8b8620ca717b095..12af3e255471c1d493354b5edb8b50e3466405a7 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InMemorySignerDecodeErrorZ extends CommonBase {
                private Result_InMemorySignerDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InMemorySignerDecodeErrorZ_get_ok(ptr);
-                       InMemorySigner res_hu_conv = new InMemorySigner(null, res);
+                       InMemorySigner res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new InMemorySigner(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_InMemorySignerDecodeErrorZ extends CommonBase {
                private Result_InMemorySignerDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_InMemorySignerDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_InMemorySignerDecodeErrorZ extends CommonBase {
         */
        public static Result_InMemorySignerDecodeErrorZ ok(InMemorySigner o) {
                long ret = bindings.CResult_InMemorySignerDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_InMemorySignerDecodeErrorZ extends CommonBase {
         */
        public static Result_InMemorySignerDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_InMemorySignerDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_InMemorySignerDecodeErrorZ extends CommonBase {
         */
        public Result_InMemorySignerDecodeErrorZ clone() {
                long ret = bindings.CResult_InMemorySignerDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 6ad9c678858ef61a1450c4d23b3f2f0572c3257b..fc4ba847dd8218e0c0ad80fb86d9d32302e2da9d 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InitDecodeErrorZ extends CommonBase {
                private Result_InitDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InitDecodeErrorZ_get_ok(ptr);
-                       Init res_hu_conv = new Init(null, res);
+                       Init res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Init(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_InitDecodeErrorZ extends CommonBase {
                private Result_InitDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_InitDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_InitDecodeErrorZ extends CommonBase {
         */
        public static Result_InitDecodeErrorZ ok(Init o) {
                long ret = bindings.CResult_InitDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_InitDecodeErrorZ extends CommonBase {
         */
        public static Result_InitDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_InitDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_InitDecodeErrorZ extends CommonBase {
         */
        public Result_InitDecodeErrorZ clone() {
                long ret = bindings.CResult_InitDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitDecodeErrorZ ret_hu_conv = Result_InitDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index e8c720c66bf80c523712b7414255d4c3952b5a0d..4ddf9e774a39aec0718646b62140b0ce3832e0dc 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InitFeaturesDecodeErrorZ extends CommonBase {
                private Result_InitFeaturesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InitFeaturesDecodeErrorZ_get_ok(ptr);
-                       InitFeatures res_hu_conv = new InitFeatures(null, res);
+                       InitFeatures res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new InitFeatures(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_InitFeaturesDecodeErrorZ extends CommonBase {
                private Result_InitFeaturesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_InitFeaturesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_InitFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_InitFeaturesDecodeErrorZ ok(InitFeatures o) {
                long ret = bindings.CResult_InitFeaturesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitFeaturesDecodeErrorZ ret_hu_conv = Result_InitFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_InitFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_InitFeaturesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_InitFeaturesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InitFeaturesDecodeErrorZ ret_hu_conv = Result_InitFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2de17bc3cc9e8c7747fff1327df18784863dc60e..c18431bbe51e98a8760516d714db90b05ae34b66 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InvoiceFeaturesDecodeErrorZ extends CommonBase {
                private Result_InvoiceFeaturesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(ptr);
-                       InvoiceFeatures res_hu_conv = new InvoiceFeatures(null, res);
+                       InvoiceFeatures res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new InvoiceFeatures(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_InvoiceFeaturesDecodeErrorZ extends CommonBase {
                private Result_InvoiceFeaturesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_InvoiceFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_InvoiceFeaturesDecodeErrorZ ok(InvoiceFeatures o) {
                long ret = bindings.CResult_InvoiceFeaturesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_InvoiceFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_InvoiceFeaturesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_InvoiceFeaturesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9b4719bf93aef1e4c0cd4c5e4743e6f31cf7bf41..47f88366116451589fcd2f4b8045a507db722ecc 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InvoiceNoneZ extends CommonBase {
                private Result_InvoiceNoneZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InvoiceNoneZ_get_ok(ptr);
-                       Invoice res_hu_conv = new Invoice(null, res);
+                       Invoice res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Invoice(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_InvoiceNoneZ extends CommonBase {
         */
        public static Result_InvoiceNoneZ ok(Invoice o) {
                long ret = bindings.CResult_InvoiceNoneZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceNoneZ ret_hu_conv = Result_InvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_InvoiceNoneZ extends CommonBase {
         */
        public static Result_InvoiceNoneZ err() {
                long ret = bindings.CResult_InvoiceNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceNoneZ ret_hu_conv = Result_InvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_InvoiceNoneZ extends CommonBase {
         */
        public Result_InvoiceNoneZ clone() {
                long ret = bindings.CResult_InvoiceNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceNoneZ ret_hu_conv = Result_InvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8ab26beba69f2aea94b54535c26b1e4d019e84b8..6f12fb2ed41817c41f8fcd6cccd0a2e4389d0541 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InvoiceSemanticErrorZ extends CommonBase {
                private Result_InvoiceSemanticErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InvoiceSemanticErrorZ_get_ok(ptr);
-                       Invoice res_hu_conv = new Invoice(null, res);
+                       Invoice res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Invoice(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_InvoiceSemanticErrorZ extends CommonBase {
         */
        public static Result_InvoiceSemanticErrorZ ok(Invoice o) {
                long ret = bindings.CResult_InvoiceSemanticErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSemanticErrorZ ret_hu_conv = Result_InvoiceSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_InvoiceSemanticErrorZ extends CommonBase {
         */
        public static Result_InvoiceSemanticErrorZ err(org.ldk.enums.SemanticError e) {
                long ret = bindings.CResult_InvoiceSemanticErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSemanticErrorZ ret_hu_conv = Result_InvoiceSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_InvoiceSemanticErrorZ extends CommonBase {
         */
        public Result_InvoiceSemanticErrorZ clone() {
                long ret = bindings.CResult_InvoiceSemanticErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSemanticErrorZ ret_hu_conv = Result_InvoiceSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 0956c2975cf10fb2f5f972a4488f71b586ebf316..c41442aa66b4e99f6347ef76dcc08e549683c0c5 100644 (file)
@@ -24,7 +24,7 @@ public class Result_InvoiceSignOrCreationErrorZ extends CommonBase {
                private Result_InvoiceSignOrCreationErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(ptr);
-                       Invoice res_hu_conv = new Invoice(null, res);
+                       Invoice res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Invoice(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_InvoiceSignOrCreationErrorZ extends CommonBase {
         */
        public static Result_InvoiceSignOrCreationErrorZ ok(Invoice o) {
                long ret = bindings.CResult_InvoiceSignOrCreationErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_InvoiceSignOrCreationErrorZ extends CommonBase {
         */
        public static Result_InvoiceSignOrCreationErrorZ err(SignOrCreationError e) {
                long ret = bindings.CResult_InvoiceSignOrCreationErrorZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_InvoiceSignOrCreationErrorZ extends CommonBase {
         */
        public Result_InvoiceSignOrCreationErrorZ clone() {
                long ret = bindings.CResult_InvoiceSignOrCreationErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index cae815845cbb294d706e16a4706cb913ad41e981..eaa3e195e0714ba9e214c30ac556f95e6926855b 100644 (file)
@@ -24,7 +24,7 @@ public class Result_LockedChannelMonitorNoneZ extends CommonBase {
                private Result_LockedChannelMonitorNoneZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_LockedChannelMonitorNoneZ_get_ok(ptr);
-                       LockedChannelMonitor res_hu_conv = new LockedChannelMonitor(null, res);
+                       LockedChannelMonitor res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new LockedChannelMonitor(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_LockedChannelMonitorNoneZ extends CommonBase {
         */
        public static Result_LockedChannelMonitorNoneZ ok(LockedChannelMonitor o) {
                long ret = bindings.CResult_LockedChannelMonitorNoneZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_LockedChannelMonitorNoneZ ret_hu_conv = Result_LockedChannelMonitorNoneZ.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"
@@ -60,7 +60,7 @@ public class Result_LockedChannelMonitorNoneZ extends CommonBase {
         */
        public static Result_LockedChannelMonitorNoneZ err() {
                long ret = bindings.CResult_LockedChannelMonitorNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_LockedChannelMonitorNoneZ ret_hu_conv = Result_LockedChannelMonitorNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 6515e37ec566e366dd643be420abd0f732145f84..e76b856eba5b334c8d803baf0593f61b9ac2c0eb 100644 (file)
@@ -35,7 +35,7 @@ public class Result_NetAddressDecodeErrorZ extends CommonBase {
                private Result_NetAddressDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NetAddressDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NetAddressDecodeErrorZ extends CommonBase {
         */
        public static Result_NetAddressDecodeErrorZ ok(NetAddress o) {
                long ret = bindings.CResult_NetAddressDecodeErrorZ_ok(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NetAddressDecodeErrorZ extends CommonBase {
         */
        public static Result_NetAddressDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NetAddressDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NetAddressDecodeErrorZ extends CommonBase {
         */
        public Result_NetAddressDecodeErrorZ clone() {
                long ret = bindings.CResult_NetAddressDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Result_NetAddressu8Z.java b/src/main/java/org/ldk/structs/Result_NetAddressu8Z.java
deleted file mode 100644 (file)
index 7ea9ff7..0000000
+++ /dev/null
@@ -1,72 +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;
-
-public class Result_NetAddressu8Z extends CommonBase {
-       private Result_NetAddressu8Z(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_NetAddressu8Z_free(ptr); } super.finalize();
-       }
-
-       static Result_NetAddressu8Z constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_NetAddressu8Z_result_ok(ptr)) {
-                       return new Result_NetAddressu8Z_OK(null, ptr);
-               } else {
-                       return new Result_NetAddressu8Z_Err(null, ptr);
-               }
-       }
-       public static final class Result_NetAddressu8Z_OK extends Result_NetAddressu8Z {
-               public final NetAddress res;
-               private Result_NetAddressu8Z_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       long res = bindings.LDKCResult_NetAddressu8Z_get_ok(ptr);
-                       NetAddress res_hu_conv = NetAddress.constr_from_ptr(res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_NetAddressu8Z_Err extends Result_NetAddressu8Z {
-               public final byte err;
-               private Result_NetAddressu8Z_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       this.err = bindings.LDKCResult_NetAddressu8Z_get_err(ptr);
-               }
-       }
-
-       /**
-        * Creates a new CResult_NetAddressu8Z in the success state.
-        */
-       public static Result_NetAddressu8Z ok(NetAddress o) {
-               long ret = bindings.CResult_NetAddressu8Z_ok(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_NetAddressu8Z in the error state.
-        */
-       public static Result_NetAddressu8Z err(byte e) {
-               long ret = bindings.CResult_NetAddressu8Z_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_NetAddressu8Z which has the same data as `orig`
-        * but with all dynamically-allocated buffers duplicated in new buffers.
-        */
-       public Result_NetAddressu8Z clone() {
-               long ret = bindings.CResult_NetAddressu8Z_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
index 8f97bcca900dbe04b7cce6fdb4157426e7dd8d84..edfb2b96ff46a4cfd7e996bc1cb53d6db9eb5847 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
                private Result_NetworkGraphDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_ok(ptr);
-                       NetworkGraph res_hu_conv = new NetworkGraph(null, res);
+                       NetworkGraph res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NetworkGraph(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
                private Result_NetworkGraphDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
         */
        public static Result_NetworkGraphDecodeErrorZ ok(NetworkGraph o) {
                long ret = bindings.CResult_NetworkGraphDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
         */
        public static Result_NetworkGraphDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NetworkGraphDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase {
         */
        public Result_NetworkGraphDecodeErrorZ clone() {
                long ret = bindings.CResult_NetworkGraphDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NetworkGraphDecodeErrorZ ret_hu_conv = Result_NetworkGraphDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 46037d929135e09e3642113ac806977409dfee1b..8687041a3f12ad703bdeb8b23325b3f96c1dfa42 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NodeAnnouncementDecodeErrorZ extends CommonBase {
                private Result_NodeAnnouncementDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(ptr);
-                       NodeAnnouncement res_hu_conv = new NodeAnnouncement(null, res);
+                       NodeAnnouncement res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NodeAnnouncement(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NodeAnnouncementDecodeErrorZ extends CommonBase {
                private Result_NodeAnnouncementDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeAnnouncementDecodeErrorZ ok(NodeAnnouncement o) {
                long ret = bindings.CResult_NodeAnnouncementDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeAnnouncementDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NodeAnnouncementDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public Result_NodeAnnouncementDecodeErrorZ clone() {
                long ret = bindings.CResult_NodeAnnouncementDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 17cb824b9888876442427dec15f360985997d8b5..399ce62444f177d1ab5e440ceaeb36487d3db3eb 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NodeAnnouncementInfoDecodeErrorZ extends CommonBase {
                private Result_NodeAnnouncementInfoDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(ptr);
-                       NodeAnnouncementInfo res_hu_conv = new NodeAnnouncementInfo(null, res);
+                       NodeAnnouncementInfo res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NodeAnnouncementInfo(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NodeAnnouncementInfoDecodeErrorZ extends CommonBase {
                private Result_NodeAnnouncementInfoDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NodeAnnouncementInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeAnnouncementInfoDecodeErrorZ ok(NodeAnnouncementInfo o) {
                long ret = bindings.CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NodeAnnouncementInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeAnnouncementInfoDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NodeAnnouncementInfoDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NodeAnnouncementInfoDecodeErrorZ extends CommonBase {
         */
        public Result_NodeAnnouncementInfoDecodeErrorZ clone() {
                long ret = bindings.CResult_NodeAnnouncementInfoDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 40353dacd512eb0a2e86d200ea608f703c249003..67a831a12562e2f2154339e746fd8699f4d69ccb 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NodeFeaturesDecodeErrorZ extends CommonBase {
                private Result_NodeFeaturesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(ptr);
-                       NodeFeatures res_hu_conv = new NodeFeatures(null, res);
+                       NodeFeatures res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NodeFeatures(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NodeFeaturesDecodeErrorZ extends CommonBase {
                private Result_NodeFeaturesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NodeFeaturesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NodeFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeFeaturesDecodeErrorZ ok(NodeFeatures o) {
                long ret = bindings.CResult_NodeFeaturesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeFeaturesDecodeErrorZ ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NodeFeaturesDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeFeaturesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NodeFeaturesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeFeaturesDecodeErrorZ ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 70b17fe79f6204287c2ffe5955cddeb52b38555b..cffb4e58ff7e4a53bfb92ca0226633609157e55c 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NodeIdDecodeErrorZ extends CommonBase {
                private Result_NodeIdDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NodeIdDecodeErrorZ_get_ok(ptr);
-                       NodeId res_hu_conv = new NodeId(null, res);
+                       NodeId res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NodeId(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NodeIdDecodeErrorZ extends CommonBase {
                private Result_NodeIdDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NodeIdDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NodeIdDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeIdDecodeErrorZ ok(NodeId o) {
                long ret = bindings.CResult_NodeIdDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NodeIdDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeIdDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NodeIdDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NodeIdDecodeErrorZ extends CommonBase {
         */
        public Result_NodeIdDecodeErrorZ clone() {
                long ret = bindings.CResult_NodeIdDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b83c1d9db81f99760fac308951f6cd287cce5fb5..94e63ac7ef363b0284daf925c75d3d59f642eac6 100644 (file)
@@ -24,7 +24,7 @@ public class Result_NodeInfoDecodeErrorZ extends CommonBase {
                private Result_NodeInfoDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_NodeInfoDecodeErrorZ_get_ok(ptr);
-                       NodeInfo res_hu_conv = new NodeInfo(null, res);
+                       NodeInfo res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new NodeInfo(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_NodeInfoDecodeErrorZ extends CommonBase {
                private Result_NodeInfoDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NodeInfoDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_NodeInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeInfoDecodeErrorZ ok(NodeInfo o) {
                long ret = bindings.CResult_NodeInfoDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_NodeInfoDecodeErrorZ extends CommonBase {
         */
        public static Result_NodeInfoDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_NodeInfoDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_NodeInfoDecodeErrorZ extends CommonBase {
         */
        public Result_NodeInfoDecodeErrorZ clone() {
                long ret = bindings.CResult_NodeInfoDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NodeInfoDecodeErrorZ ret_hu_conv = Result_NodeInfoDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d78d510e567d2de07b7fa5e6e8ee0d58b5f80294..60669eea736b7995d3b6182910fc3a0496b5712f 100644 (file)
@@ -41,7 +41,7 @@ public class Result_NoneAPIErrorZ extends CommonBase {
         */
        public static Result_NoneAPIErrorZ ok() {
                long ret = bindings.CResult_NoneAPIErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_NoneAPIErrorZ extends CommonBase {
         */
        public static Result_NoneAPIErrorZ err(APIError e) {
                long ret = bindings.CResult_NoneAPIErrorZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_NoneAPIErrorZ extends CommonBase {
         */
        public Result_NoneAPIErrorZ clone() {
                long ret = bindings.CResult_NoneAPIErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 753b1b42099b1abb889c39ffa318973d3104e6e5..7059e037b31938d61075a711c75b4e1c6cc3c373 100644 (file)
@@ -38,7 +38,7 @@ public class Result_NoneChannelMonitorUpdateErrZ extends CommonBase {
         */
        public static Result_NoneChannelMonitorUpdateErrZ ok() {
                long ret = bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_NoneChannelMonitorUpdateErrZ extends CommonBase {
         */
        public static Result_NoneChannelMonitorUpdateErrZ err(org.ldk.enums.ChannelMonitorUpdateErr e) {
                long ret = bindings.CResult_NoneChannelMonitorUpdateErrZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_NoneChannelMonitorUpdateErrZ extends CommonBase {
         */
        public Result_NoneChannelMonitorUpdateErrZ clone() {
                long ret = bindings.CResult_NoneChannelMonitorUpdateErrZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 158ece2f33ed199fee01a9933d8bebccc59eb7b8..d9b7cf490f607d56fe85049f2fc0b6903439628b 100644 (file)
@@ -38,7 +38,7 @@ public class Result_NoneErrorZ extends CommonBase {
         */
        public static Result_NoneErrorZ ok() {
                long ret = bindings.CResult_NoneErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_NoneErrorZ extends CommonBase {
         */
        public static Result_NoneErrorZ err(org.ldk.enums.IOError e) {
                long ret = bindings.CResult_NoneErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_NoneErrorZ extends CommonBase {
         */
        public Result_NoneErrorZ clone() {
                long ret = bindings.CResult_NoneErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index ca409756d716cd1999a7c570fee5a5a1a278be73..7852ba30f9dc8e1d6f6e42878bb5c4d852574625 100644 (file)
@@ -30,7 +30,7 @@ public class Result_NoneLightningErrorZ extends CommonBase {
                private Result_NoneLightningErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NoneLightningErrorZ_get_err(ptr);
-                       LightningError err_hu_conv = new LightningError(null, err);
+                       LightningError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new LightningError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_NoneLightningErrorZ extends CommonBase {
         */
        public static Result_NoneLightningErrorZ ok() {
                long ret = bindings.CResult_NoneLightningErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_NoneLightningErrorZ extends CommonBase {
         */
        public static Result_NoneLightningErrorZ err(LightningError e) {
                long ret = bindings.CResult_NoneLightningErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_NoneLightningErrorZ extends CommonBase {
         */
        public Result_NoneLightningErrorZ clone() {
                long ret = bindings.CResult_NoneLightningErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 63105160b7a84847a03e0fd655d1ee6a838fae13..6a8556b61198d3832a1f07fa7b4541d108ba10b1 100644 (file)
@@ -30,7 +30,7 @@ public class Result_NoneMonitorUpdateErrorZ extends CommonBase {
                private Result_NoneMonitorUpdateErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NoneMonitorUpdateErrorZ_get_err(ptr);
-                       MonitorUpdateError err_hu_conv = new MonitorUpdateError(null, err);
+                       MonitorUpdateError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new MonitorUpdateError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_NoneMonitorUpdateErrorZ extends CommonBase {
         */
        public static Result_NoneMonitorUpdateErrorZ ok() {
                long ret = bindings.CResult_NoneMonitorUpdateErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_NoneMonitorUpdateErrorZ extends CommonBase {
         */
        public static Result_NoneMonitorUpdateErrorZ err(MonitorUpdateError e) {
                long ret = bindings.CResult_NoneMonitorUpdateErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_NoneMonitorUpdateErrorZ extends CommonBase {
         */
        public Result_NoneMonitorUpdateErrorZ clone() {
                long ret = bindings.CResult_NoneMonitorUpdateErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index ac7db7008a20ba9c14591f1c213f84594c9269b8..3ef1d959a97548c96d09f2014963380f0ba2c026 100644 (file)
@@ -36,7 +36,7 @@ public class Result_NoneNoneZ extends CommonBase {
         */
        public static Result_NoneNoneZ ok() {
                long ret = bindings.CResult_NoneNoneZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -46,7 +46,7 @@ public class Result_NoneNoneZ extends CommonBase {
         */
        public static Result_NoneNoneZ err() {
                long ret = bindings.CResult_NoneNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -57,7 +57,7 @@ public class Result_NoneNoneZ extends CommonBase {
         */
        public Result_NoneNoneZ clone() {
                long ret = bindings.CResult_NoneNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index bb736ac0e3e8a5b7b29a9ea5aa8d6d04c740374a..9c98c59904a39723e85ff55c2c800f8a0aa0cc63 100644 (file)
@@ -41,7 +41,7 @@ public class Result_NonePaymentSendFailureZ extends CommonBase {
         */
        public static Result_NonePaymentSendFailureZ ok() {
                long ret = bindings.CResult_NonePaymentSendFailureZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_NonePaymentSendFailureZ extends CommonBase {
         */
        public static Result_NonePaymentSendFailureZ err(PaymentSendFailure e) {
                long ret = bindings.CResult_NonePaymentSendFailureZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_NonePaymentSendFailureZ extends CommonBase {
         */
        public Result_NonePaymentSendFailureZ clone() {
                long ret = bindings.CResult_NonePaymentSendFailureZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 010c67a498c0a31d6f935a42f96510d69b4732f1..b6a2804ab179f5a79fdd5a308c5b7e33fad1a119 100644 (file)
@@ -30,7 +30,7 @@ public class Result_NonePeerHandleErrorZ extends CommonBase {
                private Result_NonePeerHandleErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_NonePeerHandleErrorZ_get_err(ptr);
-                       PeerHandleError err_hu_conv = new PeerHandleError(null, err);
+                       PeerHandleError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new PeerHandleError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_NonePeerHandleErrorZ extends CommonBase {
         */
        public static Result_NonePeerHandleErrorZ ok() {
                long ret = bindings.CResult_NonePeerHandleErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_NonePeerHandleErrorZ extends CommonBase {
         */
        public static Result_NonePeerHandleErrorZ err(PeerHandleError e) {
                long ret = bindings.CResult_NonePeerHandleErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_NonePeerHandleErrorZ extends CommonBase {
         */
        public Result_NonePeerHandleErrorZ clone() {
                long ret = bindings.CResult_NonePeerHandleErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 85a9ae7adb86139610b839df00b9ab89a6071fe9..cf56e2178a7873adb368e55d55d21aba281defb1 100644 (file)
@@ -38,7 +38,7 @@ public class Result_NoneSemanticErrorZ extends CommonBase {
         */
        public static Result_NoneSemanticErrorZ ok() {
                long ret = bindings.CResult_NoneSemanticErrorZ_ok();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneSemanticErrorZ ret_hu_conv = Result_NoneSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_NoneSemanticErrorZ extends CommonBase {
         */
        public static Result_NoneSemanticErrorZ err(org.ldk.enums.SemanticError e) {
                long ret = bindings.CResult_NoneSemanticErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneSemanticErrorZ ret_hu_conv = Result_NoneSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_NoneSemanticErrorZ extends CommonBase {
         */
        public Result_NoneSemanticErrorZ clone() {
                long ret = bindings.CResult_NoneSemanticErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneSemanticErrorZ ret_hu_conv = Result_NoneSemanticErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9c2df67987d68a34336a41e4327a08b6ea301095..fd4d8c6d31a787a5cfa75b0ac8877a0857c991d1 100644 (file)
@@ -24,7 +24,7 @@ public class Result_OpenChannelDecodeErrorZ extends CommonBase {
                private Result_OpenChannelDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_OpenChannelDecodeErrorZ_get_ok(ptr);
-                       OpenChannel res_hu_conv = new OpenChannel(null, res);
+                       OpenChannel res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new OpenChannel(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_OpenChannelDecodeErrorZ extends CommonBase {
                private Result_OpenChannelDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_OpenChannelDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_OpenChannelDecodeErrorZ extends CommonBase {
         */
        public static Result_OpenChannelDecodeErrorZ ok(OpenChannel o) {
                long ret = bindings.CResult_OpenChannelDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_OpenChannelDecodeErrorZ extends CommonBase {
         */
        public static Result_OpenChannelDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_OpenChannelDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_OpenChannelDecodeErrorZ extends CommonBase {
         */
        public Result_OpenChannelDecodeErrorZ clone() {
                long ret = bindings.CResult_OpenChannelDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 39abca0942d462dc6ee903936b2e0f61c309c4bb..d430d70d3fc969d8996ddeb1efed84bc82db91a7 100644 (file)
@@ -24,7 +24,7 @@ public class Result_OutPointDecodeErrorZ extends CommonBase {
                private Result_OutPointDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_OutPointDecodeErrorZ_get_ok(ptr);
-                       OutPoint res_hu_conv = new OutPoint(null, res);
+                       OutPoint res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new OutPoint(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_OutPointDecodeErrorZ extends CommonBase {
                private Result_OutPointDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_OutPointDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_OutPointDecodeErrorZ extends CommonBase {
         */
        public static Result_OutPointDecodeErrorZ ok(OutPoint o) {
                long ret = bindings.CResult_OutPointDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_OutPointDecodeErrorZ extends CommonBase {
         */
        public static Result_OutPointDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_OutPointDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_OutPointDecodeErrorZ extends CommonBase {
         */
        public Result_OutPointDecodeErrorZ clone() {
                long ret = bindings.CResult_OutPointDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Result_PayeeDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_PayeeDecodeErrorZ.java
new file mode 100644 (file)
index 0000000..80292af
--- /dev/null
@@ -0,0 +1,75 @@
+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_PayeeDecodeErrorZ extends CommonBase {
+       private Result_PayeeDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_PayeeDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_PayeeDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_PayeeDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_PayeeDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_PayeeDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_PayeeDecodeErrorZ_OK extends Result_PayeeDecodeErrorZ {
+               public final Payee res;
+               private Result_PayeeDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long res = bindings.LDKCResult_PayeeDecodeErrorZ_get_ok(ptr);
+                       Payee res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Payee(null, res); }
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_PayeeDecodeErrorZ_Err extends Result_PayeeDecodeErrorZ {
+               public final DecodeError err;
+               private Result_PayeeDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long err = bindings.LDKCResult_PayeeDecodeErrorZ_get_err(ptr);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       /**
+        * Creates a new CResult_PayeeDecodeErrorZ in the success state.
+        */
+       public static Result_PayeeDecodeErrorZ ok(Payee o) {
+               long ret = bindings.CResult_PayeeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_PayeeDecodeErrorZ in the error state.
+        */
+       public static Result_PayeeDecodeErrorZ err(DecodeError e) {
+               long ret = bindings.CResult_PayeeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_PayeeDecodeErrorZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_PayeeDecodeErrorZ clone() {
+               long ret = bindings.CResult_PayeeDecodeErrorZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index 8cb71a550c751482418f6c2a860e1b96dcd7a521..ecf856d7fff904bf6b2100d87f33b622174d16c3 100644 (file)
@@ -24,7 +24,7 @@ public class Result_PayeePubKeyErrorZ extends CommonBase {
                private Result_PayeePubKeyErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_PayeePubKeyErrorZ_get_ok(ptr);
-                       PayeePubKey res_hu_conv = new PayeePubKey(null, res);
+                       PayeePubKey res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new PayeePubKey(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_PayeePubKeyErrorZ extends CommonBase {
         */
        public static Result_PayeePubKeyErrorZ ok(PayeePubKey o) {
                long ret = bindings.CResult_PayeePubKeyErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_PayeePubKeyErrorZ extends CommonBase {
         */
        public static Result_PayeePubKeyErrorZ err(org.ldk.enums.Secp256k1Error e) {
                long ret = bindings.CResult_PayeePubKeyErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_PayeePubKeyErrorZ extends CommonBase {
         */
        public Result_PayeePubKeyErrorZ clone() {
                long ret = bindings.CResult_PayeePubKeyErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Result_PaymentIdDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_PaymentIdDecodeErrorZ.java
deleted file mode 100644 (file)
index 1ff2739..0000000
+++ /dev/null
@@ -1,75 +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;
-
-public class Result_PaymentIdDecodeErrorZ extends CommonBase {
-       private Result_PaymentIdDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_PaymentIdDecodeErrorZ_free(ptr); } super.finalize();
-       }
-
-       static Result_PaymentIdDecodeErrorZ constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_PaymentIdDecodeErrorZ_result_ok(ptr)) {
-                       return new Result_PaymentIdDecodeErrorZ_OK(null, ptr);
-               } else {
-                       return new Result_PaymentIdDecodeErrorZ_Err(null, ptr);
-               }
-       }
-       public static final class Result_PaymentIdDecodeErrorZ_OK extends Result_PaymentIdDecodeErrorZ {
-               public final PaymentId res;
-               private Result_PaymentIdDecodeErrorZ_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       long res = bindings.LDKCResult_PaymentIdDecodeErrorZ_get_ok(ptr);
-                       PaymentId res_hu_conv = new PaymentId(null, res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_PaymentIdDecodeErrorZ_Err extends Result_PaymentIdDecodeErrorZ {
-               public final DecodeError err;
-               private Result_PaymentIdDecodeErrorZ_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       long err = bindings.LDKCResult_PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ in the success state.
-        */
-       public static Result_PaymentIdDecodeErrorZ ok(PaymentId o) {
-               long ret = bindings.CResult_PaymentIdDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_PaymentIdDecodeErrorZ in the error state.
-        */
-       public static Result_PaymentIdDecodeErrorZ err(DecodeError e) {
-               long ret = bindings.CResult_PaymentIdDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Creates a new CResult_PaymentIdDecodeErrorZ which has the same data as `orig`
-        * but with all dynamically-allocated buffers duplicated in new buffers.
-        */
-       public Result_PaymentIdDecodeErrorZ clone() {
-               long ret = bindings.CResult_PaymentIdDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
diff --git a/src/main/java/org/ldk/structs/Result_PaymentIdPaymentErrorZ.java b/src/main/java/org/ldk/structs/Result_PaymentIdPaymentErrorZ.java
new file mode 100644 (file)
index 0000000..5791e39
--- /dev/null
@@ -0,0 +1,72 @@
+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_PaymentIdPaymentErrorZ extends CommonBase {
+       private Result_PaymentIdPaymentErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_PaymentIdPaymentErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_PaymentIdPaymentErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_PaymentIdPaymentErrorZ_result_ok(ptr)) {
+                       return new Result_PaymentIdPaymentErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_PaymentIdPaymentErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_PaymentIdPaymentErrorZ_OK extends Result_PaymentIdPaymentErrorZ {
+               public final byte[] res;
+               private Result_PaymentIdPaymentErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       this.res = bindings.LDKCResult_PaymentIdPaymentErrorZ_get_ok(ptr);
+               }
+       }
+
+       public static final class Result_PaymentIdPaymentErrorZ_Err extends Result_PaymentIdPaymentErrorZ {
+               public final PaymentError err;
+               private Result_PaymentIdPaymentErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long err = bindings.LDKCResult_PaymentIdPaymentErrorZ_get_err(ptr);
+                       PaymentError err_hu_conv = PaymentError.constr_from_ptr(err);
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       /**
+        * Creates a new CResult_PaymentIdPaymentErrorZ in the success state.
+        */
+       public static Result_PaymentIdPaymentErrorZ ok(byte[] o) {
+               long ret = bindings.CResult_PaymentIdPaymentErrorZ_ok(o);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_PaymentIdPaymentErrorZ in the error state.
+        */
+       public static Result_PaymentIdPaymentErrorZ err(PaymentError e) {
+               long ret = bindings.CResult_PaymentIdPaymentErrorZ_err(e.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_PaymentIdPaymentErrorZ clone() {
+               long ret = bindings.CResult_PaymentIdPaymentErrorZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index 1bc352a9b6b9b720ecafde37be2b2d4c37f9a66f..0b10cf21cd1c5dd29941fab36eccbd91775d2292 100644 (file)
@@ -20,13 +20,10 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
                }
        }
        public static final class Result_PaymentIdPaymentSendFailureZ_OK extends Result_PaymentIdPaymentSendFailureZ {
-               public final PaymentId res;
+               public final byte[] res;
                private Result_PaymentIdPaymentSendFailureZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
-                       long res = bindings.LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(ptr);
-                       PaymentId res_hu_conv = new PaymentId(null, res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
+                       this.res = bindings.LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(ptr);
                }
        }
 
@@ -44,9 +41,9 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
        /**
         * Creates a new CResult_PaymentIdPaymentSendFailureZ in the success state.
         */
-       public static Result_PaymentIdPaymentSendFailureZ ok(PaymentId o) {
-               long ret = bindings.CResult_PaymentIdPaymentSendFailureZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static Result_PaymentIdPaymentSendFailureZ ok(byte[] o) {
+               long ret = bindings.CResult_PaymentIdPaymentSendFailureZ_ok(o);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +53,7 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
         */
        public static Result_PaymentIdPaymentSendFailureZ err(PaymentSendFailure e) {
                long ret = bindings.CResult_PaymentIdPaymentSendFailureZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +64,7 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
         */
        public Result_PaymentIdPaymentSendFailureZ clone() {
                long ret = bindings.CResult_PaymentIdPaymentSendFailureZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a05fac0029432e6b6f767b3f4e276fe48a44b7ab..2c5e9893122374ab7c25dc3415878a78adbc931e 100644 (file)
@@ -43,7 +43,7 @@ public class Result_PaymentSecretAPIErrorZ extends CommonBase {
         */
        public static Result_PaymentSecretAPIErrorZ ok(byte[] o) {
                long ret = bindings.CResult_PaymentSecretAPIErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_PaymentSecretAPIErrorZ extends CommonBase {
         */
        public static Result_PaymentSecretAPIErrorZ err(APIError e) {
                long ret = bindings.CResult_PaymentSecretAPIErrorZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_PaymentSecretAPIErrorZ extends CommonBase {
         */
        public Result_PaymentSecretAPIErrorZ clone() {
                long ret = bindings.CResult_PaymentSecretAPIErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 871f4023df9dea41920ce27e390ba1c18daea5fa..ed654d038223f823a9dbb6885d2310b139a1a6b0 100644 (file)
@@ -24,7 +24,7 @@ public class Result_PingDecodeErrorZ extends CommonBase {
                private Result_PingDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_PingDecodeErrorZ_get_ok(ptr);
-                       Ping res_hu_conv = new Ping(null, res);
+                       Ping res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Ping(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_PingDecodeErrorZ extends CommonBase {
                private Result_PingDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_PingDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_PingDecodeErrorZ extends CommonBase {
         */
        public static Result_PingDecodeErrorZ ok(Ping o) {
                long ret = bindings.CResult_PingDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_PingDecodeErrorZ extends CommonBase {
         */
        public static Result_PingDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_PingDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_PingDecodeErrorZ extends CommonBase {
         */
        public Result_PingDecodeErrorZ clone() {
                long ret = bindings.CResult_PingDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 1a356c2f5d08a3087407fe03009472b5c6087c78..53273031c4ae27a9634211186ec9e6369ba02cb2 100644 (file)
@@ -24,7 +24,7 @@ public class Result_PongDecodeErrorZ extends CommonBase {
                private Result_PongDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_PongDecodeErrorZ_get_ok(ptr);
-                       Pong res_hu_conv = new Pong(null, res);
+                       Pong res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Pong(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_PongDecodeErrorZ extends CommonBase {
                private Result_PongDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_PongDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_PongDecodeErrorZ extends CommonBase {
         */
        public static Result_PongDecodeErrorZ ok(Pong o) {
                long ret = bindings.CResult_PongDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_PongDecodeErrorZ extends CommonBase {
         */
        public static Result_PongDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_PongDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_PongDecodeErrorZ extends CommonBase {
         */
        public Result_PongDecodeErrorZ clone() {
                long ret = bindings.CResult_PongDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 33f5cedd21aed0062eee62eb8b1ce830b107c1bd..344ca77e7d5ff3da5d2c4df4f42a03e897349c88 100644 (file)
@@ -24,7 +24,7 @@ public class Result_PositiveTimestampCreationErrorZ extends CommonBase {
                private Result_PositiveTimestampCreationErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_PositiveTimestampCreationErrorZ_get_ok(ptr);
-                       PositiveTimestamp res_hu_conv = new PositiveTimestamp(null, res);
+                       PositiveTimestamp res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new PositiveTimestamp(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_PositiveTimestampCreationErrorZ extends CommonBase {
         */
        public static Result_PositiveTimestampCreationErrorZ ok(PositiveTimestamp o) {
                long ret = bindings.CResult_PositiveTimestampCreationErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_PositiveTimestampCreationErrorZ extends CommonBase {
         */
        public static Result_PositiveTimestampCreationErrorZ err(org.ldk.enums.CreationError e) {
                long ret = bindings.CResult_PositiveTimestampCreationErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_PositiveTimestampCreationErrorZ extends CommonBase {
         */
        public Result_PositiveTimestampCreationErrorZ clone() {
                long ret = bindings.CResult_PositiveTimestampCreationErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 6fc8d26fd31b6f0e06fad1f36ca8b37669440c19..8704ce8ba22675acb77826fb1101cc4f9aacac8a 100644 (file)
@@ -24,7 +24,7 @@ public class Result_PrivateRouteCreationErrorZ extends CommonBase {
                private Result_PrivateRouteCreationErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_PrivateRouteCreationErrorZ_get_ok(ptr);
-                       PrivateRoute res_hu_conv = new PrivateRoute(null, res);
+                       PrivateRoute res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new PrivateRoute(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_PrivateRouteCreationErrorZ extends CommonBase {
         */
        public static Result_PrivateRouteCreationErrorZ ok(PrivateRoute o) {
                long ret = bindings.CResult_PrivateRouteCreationErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_PrivateRouteCreationErrorZ extends CommonBase {
         */
        public static Result_PrivateRouteCreationErrorZ err(org.ldk.enums.CreationError e) {
                long ret = bindings.CResult_PrivateRouteCreationErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_PrivateRouteCreationErrorZ extends CommonBase {
         */
        public Result_PrivateRouteCreationErrorZ clone() {
                long ret = bindings.CResult_PrivateRouteCreationErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PrivateRouteCreationErrorZ ret_hu_conv = Result_PrivateRouteCreationErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 932d55ae8bc83632ee4afe8c42ca1ab32d979b82..1377bcbc69a97adba9a633dba71071a8b4fd6934 100644 (file)
@@ -40,7 +40,7 @@ public class Result_PublicKeyErrorZ extends CommonBase {
         */
        public static Result_PublicKeyErrorZ ok(byte[] o) {
                long ret = bindings.CResult_PublicKeyErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -50,7 +50,7 @@ public class Result_PublicKeyErrorZ extends CommonBase {
         */
        public static Result_PublicKeyErrorZ err(org.ldk.enums.Secp256k1Error e) {
                long ret = bindings.CResult_PublicKeyErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -61,7 +61,7 @@ public class Result_PublicKeyErrorZ extends CommonBase {
         */
        public Result_PublicKeyErrorZ clone() {
                long ret = bindings.CResult_PublicKeyErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 15fb47f7bbd5203109e9afc90a5c9ce3dc976b3b..b141a0adf788e7c921414f23436e3f06dd818afc 100644 (file)
@@ -24,7 +24,7 @@ public class Result_QueryChannelRangeDecodeErrorZ extends CommonBase {
                private Result_QueryChannelRangeDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(ptr);
-                       QueryChannelRange res_hu_conv = new QueryChannelRange(null, res);
+                       QueryChannelRange res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new QueryChannelRange(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_QueryChannelRangeDecodeErrorZ extends CommonBase {
                private Result_QueryChannelRangeDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_QueryChannelRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_QueryChannelRangeDecodeErrorZ ok(QueryChannelRange o) {
                long ret = bindings.CResult_QueryChannelRangeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_QueryChannelRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_QueryChannelRangeDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_QueryChannelRangeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_QueryChannelRangeDecodeErrorZ extends CommonBase {
         */
        public Result_QueryChannelRangeDecodeErrorZ clone() {
                long ret = bindings.CResult_QueryChannelRangeDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryChannelRangeDecodeErrorZ ret_hu_conv = Result_QueryChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d05caf584b5e8becfd29ece60d0f425a36447e06..1844c8a3532cfdb2ed490b582c39b5bc690b6ff6 100644 (file)
@@ -24,7 +24,7 @@ public class Result_QueryShortChannelIdsDecodeErrorZ extends CommonBase {
                private Result_QueryShortChannelIdsDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(ptr);
-                       QueryShortChannelIds res_hu_conv = new QueryShortChannelIds(null, res);
+                       QueryShortChannelIds res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new QueryShortChannelIds(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_QueryShortChannelIdsDecodeErrorZ extends CommonBase {
                private Result_QueryShortChannelIdsDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_QueryShortChannelIdsDecodeErrorZ extends CommonBase {
         */
        public static Result_QueryShortChannelIdsDecodeErrorZ ok(QueryShortChannelIds o) {
                long ret = bindings.CResult_QueryShortChannelIdsDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_QueryShortChannelIdsDecodeErrorZ extends CommonBase {
         */
        public static Result_QueryShortChannelIdsDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_QueryShortChannelIdsDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_QueryShortChannelIdsDecodeErrorZ extends CommonBase {
         */
        public Result_QueryShortChannelIdsDecodeErrorZ clone() {
                long ret = bindings.CResult_QueryShortChannelIdsDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_QueryShortChannelIdsDecodeErrorZ ret_hu_conv = Result_QueryShortChannelIdsDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2f2f54e20f3c36d3b49d57b682781a439bf5a769..29b5001fc60f62687273e4b890c3087fabe61bf1 100644 (file)
@@ -38,7 +38,7 @@ public class Result_RecoverableSignatureNoneZ extends CommonBase {
         */
        public static Result_RecoverableSignatureNoneZ ok(byte[] arg) {
                long ret = bindings.CResult_RecoverableSignatureNoneZ_ok(arg);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_RecoverableSignatureNoneZ extends CommonBase {
         */
        public static Result_RecoverableSignatureNoneZ err() {
                long ret = bindings.CResult_RecoverableSignatureNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_RecoverableSignatureNoneZ extends CommonBase {
         */
        public Result_RecoverableSignatureNoneZ clone() {
                long ret = bindings.CResult_RecoverableSignatureNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8a49998d18ecdd057ae4b739a62e7913ae74dd13..3f7b4e2cbbe0f116f25f31cb37e7e742b2fc40de 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ReplyChannelRangeDecodeErrorZ extends CommonBase {
                private Result_ReplyChannelRangeDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(ptr);
-                       ReplyChannelRange res_hu_conv = new ReplyChannelRange(null, res);
+                       ReplyChannelRange res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ReplyChannelRange(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ReplyChannelRangeDecodeErrorZ extends CommonBase {
                private Result_ReplyChannelRangeDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ReplyChannelRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_ReplyChannelRangeDecodeErrorZ ok(ReplyChannelRange o) {
                long ret = bindings.CResult_ReplyChannelRangeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ReplyChannelRangeDecodeErrorZ extends CommonBase {
         */
        public static Result_ReplyChannelRangeDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ReplyChannelRangeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ReplyChannelRangeDecodeErrorZ extends CommonBase {
         */
        public Result_ReplyChannelRangeDecodeErrorZ clone() {
                long ret = bindings.CResult_ReplyChannelRangeDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 4038ac89dfb652833e8e0f2fb200971524d29607..bba3338027888eea4111a07858457b31dcea971c 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ReplyShortChannelIdsEndDecodeErrorZ extends CommonBase {
                private Result_ReplyShortChannelIdsEndDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(ptr);
-                       ReplyShortChannelIdsEnd res_hu_conv = new ReplyShortChannelIdsEnd(null, res);
+                       ReplyShortChannelIdsEnd res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ReplyShortChannelIdsEnd(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ReplyShortChannelIdsEndDecodeErrorZ extends CommonBase {
                private Result_ReplyShortChannelIdsEndDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ReplyShortChannelIdsEndDecodeErrorZ extends CommonBase {
         */
        public static Result_ReplyShortChannelIdsEndDecodeErrorZ ok(ReplyShortChannelIdsEnd o) {
                long ret = bindings.CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ReplyShortChannelIdsEndDecodeErrorZ extends CommonBase {
         */
        public static Result_ReplyShortChannelIdsEndDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ReplyShortChannelIdsEndDecodeErrorZ extends CommonBase {
         */
        public Result_ReplyShortChannelIdsEndDecodeErrorZ clone() {
                long ret = bindings.CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ReplyShortChannelIdsEndDecodeErrorZ ret_hu_conv = Result_ReplyShortChannelIdsEndDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8a979c3ed0def51c2ad0b25cd113cfe9e98b532c..679192debb1e2a05da966026b5a7ca817a7c219d 100644 (file)
@@ -24,7 +24,7 @@ public class Result_RevokeAndACKDecodeErrorZ extends CommonBase {
                private Result_RevokeAndACKDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(ptr);
-                       RevokeAndACK res_hu_conv = new RevokeAndACK(null, res);
+                       RevokeAndACK res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RevokeAndACK(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_RevokeAndACKDecodeErrorZ extends CommonBase {
                private Result_RevokeAndACKDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_RevokeAndACKDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_RevokeAndACKDecodeErrorZ extends CommonBase {
         */
        public static Result_RevokeAndACKDecodeErrorZ ok(RevokeAndACK o) {
                long ret = bindings.CResult_RevokeAndACKDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_RevokeAndACKDecodeErrorZ extends CommonBase {
         */
        public static Result_RevokeAndACKDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_RevokeAndACKDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_RevokeAndACKDecodeErrorZ extends CommonBase {
         */
        public Result_RevokeAndACKDecodeErrorZ clone() {
                long ret = bindings.CResult_RevokeAndACKDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8da8f3533b502053170c619dc8ce929b02b01640..f3248f06044b2d06873a65cbec2e4fe1558b5461 100644 (file)
@@ -24,7 +24,7 @@ public class Result_RouteDecodeErrorZ extends CommonBase {
                private Result_RouteDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_RouteDecodeErrorZ_get_ok(ptr);
-                       Route res_hu_conv = new Route(null, res);
+                       Route res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Route(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_RouteDecodeErrorZ extends CommonBase {
                private Result_RouteDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_RouteDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_RouteDecodeErrorZ extends CommonBase {
         */
        public static Result_RouteDecodeErrorZ ok(Route o) {
                long ret = bindings.CResult_RouteDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_RouteDecodeErrorZ extends CommonBase {
         */
        public static Result_RouteDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_RouteDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_RouteDecodeErrorZ extends CommonBase {
         */
        public Result_RouteDecodeErrorZ clone() {
                long ret = bindings.CResult_RouteDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Result_RouteHintDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_RouteHintDecodeErrorZ.java
new file mode 100644 (file)
index 0000000..37d44ea
--- /dev/null
@@ -0,0 +1,75 @@
+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_RouteHintDecodeErrorZ extends CommonBase {
+       private Result_RouteHintDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteHintDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteHintDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteHintDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteHintDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteHintDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteHintDecodeErrorZ_OK extends Result_RouteHintDecodeErrorZ {
+               public final RouteHint res;
+               private Result_RouteHintDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long res = bindings.LDKCResult_RouteHintDecodeErrorZ_get_ok(ptr);
+                       RouteHint res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RouteHint(null, res); }
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteHintDecodeErrorZ_Err extends Result_RouteHintDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteHintDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long err = bindings.LDKCResult_RouteHintDecodeErrorZ_get_err(ptr);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       /**
+        * Creates a new CResult_RouteHintDecodeErrorZ in the success state.
+        */
+       public static Result_RouteHintDecodeErrorZ ok(RouteHint o) {
+               long ret = bindings.CResult_RouteHintDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteHintDecodeErrorZ in the error state.
+        */
+       public static Result_RouteHintDecodeErrorZ err(DecodeError e) {
+               long ret = bindings.CResult_RouteHintDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_RouteHintDecodeErrorZ clone() {
+               long ret = bindings.CResult_RouteHintDecodeErrorZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/src/main/java/org/ldk/structs/Result_RouteHintHopDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_RouteHintHopDecodeErrorZ.java
new file mode 100644 (file)
index 0000000..ed9fe14
--- /dev/null
@@ -0,0 +1,75 @@
+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_RouteHintHopDecodeErrorZ extends CommonBase {
+       private Result_RouteHintHopDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteHintHopDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteHintHopDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteHintHopDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteHintHopDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteHintHopDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteHintHopDecodeErrorZ_OK extends Result_RouteHintHopDecodeErrorZ {
+               public final RouteHintHop res;
+               private Result_RouteHintHopDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long res = bindings.LDKCResult_RouteHintHopDecodeErrorZ_get_ok(ptr);
+                       RouteHintHop res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RouteHintHop(null, res); }
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteHintHopDecodeErrorZ_Err extends Result_RouteHintHopDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteHintHopDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long err = bindings.LDKCResult_RouteHintHopDecodeErrorZ_get_err(ptr);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       /**
+        * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state.
+        */
+       public static Result_RouteHintHopDecodeErrorZ ok(RouteHintHop o) {
+               long ret = bindings.CResult_RouteHintHopDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state.
+        */
+       public static Result_RouteHintHopDecodeErrorZ err(DecodeError e) {
+               long ret = bindings.CResult_RouteHintHopDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_RouteHintHopDecodeErrorZ clone() {
+               long ret = bindings.CResult_RouteHintHopDecodeErrorZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index 45e1bde7fa849fa75bfde6035ec9a41684ef1788..32c894e52aa77838ab10a62e41bd2dbc1b36104b 100644 (file)
@@ -24,7 +24,7 @@ public class Result_RouteHopDecodeErrorZ extends CommonBase {
                private Result_RouteHopDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_RouteHopDecodeErrorZ_get_ok(ptr);
-                       RouteHop res_hu_conv = new RouteHop(null, res);
+                       RouteHop res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RouteHop(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_RouteHopDecodeErrorZ extends CommonBase {
                private Result_RouteHopDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_RouteHopDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_RouteHopDecodeErrorZ extends CommonBase {
         */
        public static Result_RouteHopDecodeErrorZ ok(RouteHop o) {
                long ret = bindings.CResult_RouteHopDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_RouteHopDecodeErrorZ extends CommonBase {
         */
        public static Result_RouteHopDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_RouteHopDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_RouteHopDecodeErrorZ extends CommonBase {
         */
        public Result_RouteHopDecodeErrorZ clone() {
                long ret = bindings.CResult_RouteHopDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b14b5d9e89659b25942c702b6c9260257d38c8ac..ce8e67bc62beb07d41bad77a94bd51bcd7620043 100644 (file)
@@ -24,7 +24,7 @@ public class Result_RouteLightningErrorZ extends CommonBase {
                private Result_RouteLightningErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_RouteLightningErrorZ_get_ok(ptr);
-                       Route res_hu_conv = new Route(null, res);
+                       Route res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Route(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_RouteLightningErrorZ extends CommonBase {
                private Result_RouteLightningErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_RouteLightningErrorZ_get_err(ptr);
-                       LightningError err_hu_conv = new LightningError(null, err);
+                       LightningError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new LightningError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_RouteLightningErrorZ extends CommonBase {
         */
        public static Result_RouteLightningErrorZ ok(Route o) {
                long ret = bindings.CResult_RouteLightningErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_RouteLightningErrorZ extends CommonBase {
         */
        public static Result_RouteLightningErrorZ err(LightningError e) {
                long ret = bindings.CResult_RouteLightningErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_RouteLightningErrorZ extends CommonBase {
         */
        public Result_RouteLightningErrorZ clone() {
                long ret = bindings.CResult_RouteLightningErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/Result_RouteParametersDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_RouteParametersDecodeErrorZ.java
new file mode 100644 (file)
index 0000000..aa19d4a
--- /dev/null
@@ -0,0 +1,75 @@
+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_RouteParametersDecodeErrorZ extends CommonBase {
+       private Result_RouteParametersDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteParametersDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteParametersDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteParametersDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteParametersDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteParametersDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteParametersDecodeErrorZ_OK extends Result_RouteParametersDecodeErrorZ {
+               public final RouteParameters res;
+               private Result_RouteParametersDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long res = bindings.LDKCResult_RouteParametersDecodeErrorZ_get_ok(ptr);
+                       RouteParameters res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RouteParameters(null, res); }
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteParametersDecodeErrorZ_Err extends Result_RouteParametersDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteParametersDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       long err = bindings.LDKCResult_RouteParametersDecodeErrorZ_get_err(ptr);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       /**
+        * Creates a new CResult_RouteParametersDecodeErrorZ in the success state.
+        */
+       public static Result_RouteParametersDecodeErrorZ ok(RouteParameters o) {
+               long ret = bindings.CResult_RouteParametersDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteParametersDecodeErrorZ in the error state.
+        */
+       public static Result_RouteParametersDecodeErrorZ err(DecodeError e) {
+               long ret = bindings.CResult_RouteParametersDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_RouteParametersDecodeErrorZ clone() {
+               long ret = bindings.CResult_RouteParametersDecodeErrorZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index c6139115b4c25ba602cb7b26673623a32e62f4f2..8f691df23d62b19db227c08cbbc45305dba682e1 100644 (file)
@@ -24,7 +24,7 @@ public class Result_RoutingFeesDecodeErrorZ extends CommonBase {
                private Result_RoutingFeesDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_RoutingFeesDecodeErrorZ_get_ok(ptr);
-                       RoutingFees res_hu_conv = new RoutingFees(null, res);
+                       RoutingFees res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new RoutingFees(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_RoutingFeesDecodeErrorZ extends CommonBase {
                private Result_RoutingFeesDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_RoutingFeesDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_RoutingFeesDecodeErrorZ extends CommonBase {
         */
        public static Result_RoutingFeesDecodeErrorZ ok(RoutingFees o) {
                long ret = bindings.CResult_RoutingFeesDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RoutingFeesDecodeErrorZ ret_hu_conv = Result_RoutingFeesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_RoutingFeesDecodeErrorZ extends CommonBase {
         */
        public static Result_RoutingFeesDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_RoutingFeesDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RoutingFeesDecodeErrorZ ret_hu_conv = Result_RoutingFeesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_RoutingFeesDecodeErrorZ extends CommonBase {
         */
        public Result_RoutingFeesDecodeErrorZ clone() {
                long ret = bindings.CResult_RoutingFeesDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RoutingFeesDecodeErrorZ ret_hu_conv = Result_RoutingFeesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2e1bbd1f29f30a70a21b63d5fb61a3be9377e6df..e310f54786532ebb8adcb4252cd2373485b88d0f 100644 (file)
@@ -40,7 +40,7 @@ public class Result_SecretKeyErrorZ extends CommonBase {
         */
        public static Result_SecretKeyErrorZ ok(byte[] o) {
                long ret = bindings.CResult_SecretKeyErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -50,7 +50,7 @@ public class Result_SecretKeyErrorZ extends CommonBase {
         */
        public static Result_SecretKeyErrorZ err(org.ldk.enums.Secp256k1Error e) {
                long ret = bindings.CResult_SecretKeyErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9c6f32744c06ef5e693e1d02582357a080674440..cee6aa8a7e5ed7990e66b7f9413113dc800b7eb5 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ShutdownDecodeErrorZ extends CommonBase {
                private Result_ShutdownDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ShutdownDecodeErrorZ_get_ok(ptr);
-                       Shutdown res_hu_conv = new Shutdown(null, res);
+                       Shutdown res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new Shutdown(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ShutdownDecodeErrorZ extends CommonBase {
                private Result_ShutdownDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ShutdownDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ShutdownDecodeErrorZ extends CommonBase {
         */
        public static Result_ShutdownDecodeErrorZ ok(Shutdown o) {
                long ret = bindings.CResult_ShutdownDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ShutdownDecodeErrorZ extends CommonBase {
         */
        public static Result_ShutdownDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ShutdownDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ShutdownDecodeErrorZ extends CommonBase {
         */
        public Result_ShutdownDecodeErrorZ clone() {
                long ret = bindings.CResult_ShutdownDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 530fb84fc31b4e3e97b0866254f5feef58fe14be..96b1412e36cdf526641b68ff16552f26f8ba302e 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ShutdownScriptDecodeErrorZ extends CommonBase {
                private Result_ShutdownScriptDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(ptr);
-                       ShutdownScript res_hu_conv = new ShutdownScript(null, res);
+                       ShutdownScript res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ShutdownScript(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ShutdownScriptDecodeErrorZ extends CommonBase {
                private Result_ShutdownScriptDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ShutdownScriptDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ShutdownScriptDecodeErrorZ extends CommonBase {
         */
        public static Result_ShutdownScriptDecodeErrorZ ok(ShutdownScript o) {
                long ret = bindings.CResult_ShutdownScriptDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptDecodeErrorZ ret_hu_conv = Result_ShutdownScriptDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_ShutdownScriptDecodeErrorZ extends CommonBase {
         */
        public static Result_ShutdownScriptDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_ShutdownScriptDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptDecodeErrorZ ret_hu_conv = Result_ShutdownScriptDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_ShutdownScriptDecodeErrorZ extends CommonBase {
         */
        public Result_ShutdownScriptDecodeErrorZ clone() {
                long ret = bindings.CResult_ShutdownScriptDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptDecodeErrorZ ret_hu_conv = Result_ShutdownScriptDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 3d516e83d7c407ce42436106e669beda05dce1fb..420b036df584007a6e07499135140766aa1e5353 100644 (file)
@@ -24,7 +24,7 @@ public class Result_ShutdownScriptInvalidShutdownScriptZ extends CommonBase {
                private Result_ShutdownScriptInvalidShutdownScriptZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(ptr);
-                       ShutdownScript res_hu_conv = new ShutdownScript(null, res);
+                       ShutdownScript res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new ShutdownScript(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_ShutdownScriptInvalidShutdownScriptZ extends CommonBase {
                private Result_ShutdownScriptInvalidShutdownScriptZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(ptr);
-                       InvalidShutdownScript err_hu_conv = new InvalidShutdownScript(null, err);
+                       InvalidShutdownScript err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new InvalidShutdownScript(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_ShutdownScriptInvalidShutdownScriptZ extends CommonBase {
         */
        public static Result_ShutdownScriptInvalidShutdownScriptZ ok(ShutdownScript o) {
                long ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -54,9 +54,20 @@ public class Result_ShutdownScriptInvalidShutdownScriptZ extends CommonBase {
        /**
         * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state.
         */
-       public static Result_ShutdownScriptInvalidShutdownScriptZ err(byte[] e_script_arg) {
-               long ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_err(bindings.InvalidShutdownScript_new(e_script_arg));
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static Result_ShutdownScriptInvalidShutdownScriptZ err(InvalidShutdownScript e) {
+               long ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_err(e == null ? 0 : e.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_ShutdownScriptInvalidShutdownScriptZ clone() {
+               long ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a6717bd924aed78b869823610231f727eb016bce..0cd22a385b190f608ca14fb5d2aec15766cca98c 100644 (file)
@@ -38,7 +38,7 @@ public class Result_SiPrefixNoneZ extends CommonBase {
         */
        public static Result_SiPrefixNoneZ ok(org.ldk.enums.SiPrefix o) {
                long ret = bindings.CResult_SiPrefixNoneZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SiPrefixNoneZ ret_hu_conv = Result_SiPrefixNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_SiPrefixNoneZ extends CommonBase {
         */
        public static Result_SiPrefixNoneZ err() {
                long ret = bindings.CResult_SiPrefixNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SiPrefixNoneZ ret_hu_conv = Result_SiPrefixNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_SiPrefixNoneZ extends CommonBase {
         */
        public Result_SiPrefixNoneZ clone() {
                long ret = bindings.CResult_SiPrefixNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SiPrefixNoneZ ret_hu_conv = Result_SiPrefixNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 1ab2618e932ba1e1c5e5aaef3f03c544a9b8ef6a..75cf6d78f2ccfc381ac1be4d41be96a9ff090da3 100644 (file)
@@ -35,7 +35,7 @@ public class Result_SignDecodeErrorZ extends CommonBase {
                private Result_SignDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_SignDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_SignDecodeErrorZ extends CommonBase {
         */
        public static Result_SignDecodeErrorZ ok(Sign o) {
                long ret = bindings.CResult_SignDecodeErrorZ_ok(o == null ? 0 : o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(o);
                return ret_hu_conv;
@@ -57,7 +57,7 @@ public class Result_SignDecodeErrorZ extends CommonBase {
         */
        public static Result_SignDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_SignDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -68,7 +68,7 @@ public class Result_SignDecodeErrorZ extends CommonBase {
         */
        public Result_SignDecodeErrorZ clone() {
                long ret = bindings.CResult_SignDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5ab9f465e84957202cc49c6981c037df2990bfc7..5145441b9a6aeafdcef39451ad929a5eff31e5b9 100644 (file)
@@ -38,7 +38,7 @@ public class Result_SignatureNoneZ extends CommonBase {
         */
        public static Result_SignatureNoneZ ok(byte[] o) {
                long ret = bindings.CResult_SignatureNoneZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_SignatureNoneZ extends CommonBase {
         */
        public static Result_SignatureNoneZ err() {
                long ret = bindings.CResult_SignatureNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_SignatureNoneZ extends CommonBase {
         */
        public Result_SignatureNoneZ clone() {
                long ret = bindings.CResult_SignatureNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index b1b29e5d575544e84adb1d447cfff855696b1c02..765bca5d46e7be96b73213c99949a1e833e72750 100644 (file)
@@ -24,7 +24,7 @@ public class Result_SignedRawInvoiceNoneZ extends CommonBase {
                private Result_SignedRawInvoiceNoneZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_SignedRawInvoiceNoneZ_get_ok(ptr);
-                       SignedRawInvoice res_hu_conv = new SignedRawInvoice(null, res);
+                       SignedRawInvoice res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new SignedRawInvoice(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_SignedRawInvoiceNoneZ extends CommonBase {
         */
        public static Result_SignedRawInvoiceNoneZ ok(SignedRawInvoice o) {
                long ret = bindings.CResult_SignedRawInvoiceNoneZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -51,7 +51,7 @@ public class Result_SignedRawInvoiceNoneZ extends CommonBase {
         */
        public static Result_SignedRawInvoiceNoneZ err() {
                long ret = bindings.CResult_SignedRawInvoiceNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class Result_SignedRawInvoiceNoneZ extends CommonBase {
         */
        public Result_SignedRawInvoiceNoneZ clone() {
                long ret = bindings.CResult_SignedRawInvoiceNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 36d2291e5b543c2f908194226b7389f6d424a891..64f555367cc92d05f67e033849fa66880119336c 100644 (file)
@@ -35,7 +35,7 @@ public class Result_SpendableOutputDescriptorDecodeErrorZ extends CommonBase {
                private Result_SpendableOutputDescriptorDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_SpendableOutputDescriptorDecodeErrorZ extends CommonBase {
         */
        public static Result_SpendableOutputDescriptorDecodeErrorZ ok(SpendableOutputDescriptor o) {
                long ret = bindings.CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_SpendableOutputDescriptorDecodeErrorZ extends CommonBase {
         */
        public static Result_SpendableOutputDescriptorDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_SpendableOutputDescriptorDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_SpendableOutputDescriptorDecodeErrorZ extends CommonBase {
         */
        public Result_SpendableOutputDescriptorDecodeErrorZ clone() {
                long ret = bindings.CResult_SpendableOutputDescriptorDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 18de8c635d2354dd7f9e88e0506a55debedae148..442ef14fb44d6805040cdeea8142f81ed729109e 100644 (file)
@@ -24,7 +24,7 @@ public class Result_StaticPaymentOutputDescriptorDecodeErrorZ extends CommonBase
                private Result_StaticPaymentOutputDescriptorDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(ptr);
-                       StaticPaymentOutputDescriptor res_hu_conv = new StaticPaymentOutputDescriptor(null, res);
+                       StaticPaymentOutputDescriptor res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new StaticPaymentOutputDescriptor(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_StaticPaymentOutputDescriptorDecodeErrorZ extends CommonBase
                private Result_StaticPaymentOutputDescriptorDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_StaticPaymentOutputDescriptorDecodeErrorZ extends CommonBase
         */
        public static Result_StaticPaymentOutputDescriptorDecodeErrorZ ok(StaticPaymentOutputDescriptor o) {
                long ret = bindings.CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_StaticPaymentOutputDescriptorDecodeErrorZ extends CommonBase
         */
        public static Result_StaticPaymentOutputDescriptorDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_StaticPaymentOutputDescriptorDecodeErrorZ extends CommonBase
         */
        public Result_StaticPaymentOutputDescriptorDecodeErrorZ clone() {
                long ret = bindings.CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9439ef68e6ae0fdac1e65d6708ffe02f6a59fb0b..a9ef377676c41557455257b84878591c214a6546 100644 (file)
@@ -40,7 +40,7 @@ public class Result_StringErrorZ extends CommonBase {
         */
        public static Result_StringErrorZ ok(java.lang.String o) {
                long ret = bindings.CResult_StringErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -50,7 +50,7 @@ public class Result_StringErrorZ extends CommonBase {
         */
        public static Result_StringErrorZ err(org.ldk.enums.Secp256k1Error e) {
                long ret = bindings.CResult_StringErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 2466358a2b5b2b2071ccf0353f877b02e77902af..de1757aa95e6db84626dfd928e1a3688590e78f3 100644 (file)
@@ -38,7 +38,7 @@ public class Result_TransactionNoneZ extends CommonBase {
         */
        public static Result_TransactionNoneZ ok(byte[] o) {
                long ret = bindings.CResult_TransactionNoneZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -48,7 +48,7 @@ public class Result_TransactionNoneZ extends CommonBase {
         */
        public static Result_TransactionNoneZ err() {
                long ret = bindings.CResult_TransactionNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -59,7 +59,7 @@ public class Result_TransactionNoneZ extends CommonBase {
         */
        public Result_TransactionNoneZ clone() {
                long ret = bindings.CResult_TransactionNoneZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index fd3977c8feb96f6c7d4ecbb88a005683140891ce..814f7e99f85593c076baf980c21286285cafd5d7 100644 (file)
@@ -24,7 +24,7 @@ public class Result_TrustedClosingTransactionNoneZ extends CommonBase {
                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);
+                       TrustedClosingTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new TrustedClosingTransaction(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_TrustedClosingTransactionNoneZ extends CommonBase {
         */
        public static Result_TrustedClosingTransactionNoneZ ok(TrustedClosingTransaction o) {
                long ret = bindings.CResult_TrustedClosingTransactionNoneZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { 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"
@@ -60,7 +60,7 @@ public class Result_TrustedClosingTransactionNoneZ extends CommonBase {
         */
        public static Result_TrustedClosingTransactionNoneZ err() {
                long ret = bindings.CResult_TrustedClosingTransactionNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 1051dd7db2ad558ba03cd7dc5852646ac7be364c..3beed26aabef06cca5a9c1b150e274b7f647d592 100644 (file)
@@ -24,7 +24,7 @@ public class Result_TrustedCommitmentTransactionNoneZ extends CommonBase {
                private Result_TrustedCommitmentTransactionNoneZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(ptr);
-                       TrustedCommitmentTransaction res_hu_conv = new TrustedCommitmentTransaction(null, res);
+                       TrustedCommitmentTransaction res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new TrustedCommitmentTransaction(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -41,7 +41,7 @@ public class Result_TrustedCommitmentTransactionNoneZ extends CommonBase {
         */
        public static Result_TrustedCommitmentTransactionNoneZ ok(TrustedCommitmentTransaction o) {
                long ret = bindings.CResult_TrustedCommitmentTransactionNoneZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.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"
@@ -60,7 +60,7 @@ public class Result_TrustedCommitmentTransactionNoneZ extends CommonBase {
         */
        public static Result_TrustedCommitmentTransactionNoneZ err() {
                long ret = bindings.CResult_TrustedCommitmentTransactionNoneZ_err();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index cf6d3ee7855b232bf07685d1d42fdef7d88bcc87..1ec672799d3887e4a89fa32af590cfbfde987ba1 100644 (file)
@@ -24,7 +24,7 @@ public class Result_TxCreationKeysDecodeErrorZ extends CommonBase {
                private Result_TxCreationKeysDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(ptr);
-                       TxCreationKeys res_hu_conv = new TxCreationKeys(null, res);
+                       TxCreationKeys res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new TxCreationKeys(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_TxCreationKeysDecodeErrorZ extends CommonBase {
                private Result_TxCreationKeysDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_TxCreationKeysDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_TxCreationKeysDecodeErrorZ extends CommonBase {
         */
        public static Result_TxCreationKeysDecodeErrorZ ok(TxCreationKeys o) {
                long ret = bindings.CResult_TxCreationKeysDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_TxCreationKeysDecodeErrorZ extends CommonBase {
         */
        public static Result_TxCreationKeysDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_TxCreationKeysDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_TxCreationKeysDecodeErrorZ extends CommonBase {
         */
        public Result_TxCreationKeysDecodeErrorZ clone() {
                long ret = bindings.CResult_TxCreationKeysDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 8c95e56585012538d18841746132100b3b38f36f..564219efdf15807a7d04394f135f48fb1212090b 100644 (file)
@@ -24,7 +24,7 @@ public class Result_TxCreationKeysErrorZ extends CommonBase {
                private Result_TxCreationKeysErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_TxCreationKeysErrorZ_get_ok(ptr);
-                       TxCreationKeys res_hu_conv = new TxCreationKeys(null, res);
+                       TxCreationKeys res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new TxCreationKeys(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_TxCreationKeysErrorZ extends CommonBase {
         */
        public static Result_TxCreationKeysErrorZ ok(TxCreationKeys o) {
                long ret = bindings.CResult_TxCreationKeysErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_TxCreationKeysErrorZ extends CommonBase {
         */
        public static Result_TxCreationKeysErrorZ err(org.ldk.enums.Secp256k1Error e) {
                long ret = bindings.CResult_TxCreationKeysErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_TxCreationKeysErrorZ extends CommonBase {
         */
        public Result_TxCreationKeysErrorZ clone() {
                long ret = bindings.CResult_TxCreationKeysErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 21e2ca1e25315866f177e8caebb6d55193068045..98ff1b539acb23416689ba337ab642cccb761bde 100644 (file)
@@ -42,7 +42,7 @@ public class Result_TxOutAccessErrorZ extends CommonBase {
         */
        public static Result_TxOutAccessErrorZ ok(TxOut o) {
                long ret = bindings.CResult_TxOutAccessErrorZ_ok(o.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -52,7 +52,7 @@ public class Result_TxOutAccessErrorZ extends CommonBase {
         */
        public static Result_TxOutAccessErrorZ err(org.ldk.enums.AccessError e) {
                long ret = bindings.CResult_TxOutAccessErrorZ_err(e);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -63,7 +63,7 @@ public class Result_TxOutAccessErrorZ extends CommonBase {
         */
        public Result_TxOutAccessErrorZ clone() {
                long ret = bindings.CResult_TxOutAccessErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d442f6fb57c4e8284d7ec7bbabb3872d5f797de6..fe6e0b18c1673b3581770eb664d09beaecc6ae5f 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UnsignedChannelAnnouncementDecodeErrorZ extends CommonBase {
                private Result_UnsignedChannelAnnouncementDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(ptr);
-                       UnsignedChannelAnnouncement res_hu_conv = new UnsignedChannelAnnouncement(null, res);
+                       UnsignedChannelAnnouncement res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UnsignedChannelAnnouncement(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UnsignedChannelAnnouncementDecodeErrorZ extends CommonBase {
                private Result_UnsignedChannelAnnouncementDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UnsignedChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedChannelAnnouncementDecodeErrorZ ok(UnsignedChannelAnnouncement o) {
                long ret = bindings.CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UnsignedChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedChannelAnnouncementDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UnsignedChannelAnnouncementDecodeErrorZ extends CommonBase {
         */
        public Result_UnsignedChannelAnnouncementDecodeErrorZ clone() {
                long ret = bindings.CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 21d96fa89883e8327f54056e35af78ea04ac62a1..f3d60337c83194e0f1835f05d69a8cf9464fd59f 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UnsignedChannelUpdateDecodeErrorZ extends CommonBase {
                private Result_UnsignedChannelUpdateDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(ptr);
-                       UnsignedChannelUpdate res_hu_conv = new UnsignedChannelUpdate(null, res);
+                       UnsignedChannelUpdate res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UnsignedChannelUpdate(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UnsignedChannelUpdateDecodeErrorZ extends CommonBase {
                private Result_UnsignedChannelUpdateDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UnsignedChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedChannelUpdateDecodeErrorZ ok(UnsignedChannelUpdate o) {
                long ret = bindings.CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UnsignedChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedChannelUpdateDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UnsignedChannelUpdateDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UnsignedChannelUpdateDecodeErrorZ extends CommonBase {
         */
        public Result_UnsignedChannelUpdateDecodeErrorZ clone() {
                long ret = bindings.CResult_UnsignedChannelUpdateDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d52944e7d3945672eb9c357e7174e598dcf8c991..872d4cf3f95f9b353413800932df51eb6f999332 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UnsignedNodeAnnouncementDecodeErrorZ extends CommonBase {
                private Result_UnsignedNodeAnnouncementDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(ptr);
-                       UnsignedNodeAnnouncement res_hu_conv = new UnsignedNodeAnnouncement(null, res);
+                       UnsignedNodeAnnouncement res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UnsignedNodeAnnouncement(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UnsignedNodeAnnouncementDecodeErrorZ extends CommonBase {
                private Result_UnsignedNodeAnnouncementDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UnsignedNodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedNodeAnnouncementDecodeErrorZ ok(UnsignedNodeAnnouncement o) {
                long ret = bindings.CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UnsignedNodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public static Result_UnsignedNodeAnnouncementDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UnsignedNodeAnnouncementDecodeErrorZ extends CommonBase {
         */
        public Result_UnsignedNodeAnnouncementDecodeErrorZ clone() {
                long ret = bindings.CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 74a25abfa6e4ba5cbc8bacbdef4638b04d1ef867..d76ab972a199e621fa22892769010db3fe08adcf 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UpdateAddHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateAddHTLCDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(ptr);
-                       UpdateAddHTLC res_hu_conv = new UpdateAddHTLC(null, res);
+                       UpdateAddHTLC res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UpdateAddHTLC(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UpdateAddHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateAddHTLCDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UpdateAddHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateAddHTLCDecodeErrorZ ok(UpdateAddHTLC o) {
                long ret = bindings.CResult_UpdateAddHTLCDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UpdateAddHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateAddHTLCDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UpdateAddHTLCDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UpdateAddHTLCDecodeErrorZ extends CommonBase {
         */
        public Result_UpdateAddHTLCDecodeErrorZ clone() {
                long ret = bindings.CResult_UpdateAddHTLCDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index d0c051cd408bd493d27e94f27a05d10885fcf15f..aaa91edbb175cf36edfe0ca9e9dcb0b739c0d131 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UpdateFailHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFailHTLCDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(ptr);
-                       UpdateFailHTLC res_hu_conv = new UpdateFailHTLC(null, res);
+                       UpdateFailHTLC res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UpdateFailHTLC(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UpdateFailHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFailHTLCDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UpdateFailHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFailHTLCDecodeErrorZ ok(UpdateFailHTLC o) {
                long ret = bindings.CResult_UpdateFailHTLCDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UpdateFailHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFailHTLCDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UpdateFailHTLCDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UpdateFailHTLCDecodeErrorZ extends CommonBase {
         */
        public Result_UpdateFailHTLCDecodeErrorZ clone() {
                long ret = bindings.CResult_UpdateFailHTLCDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 07661e23222a76f17caf2a33a9fe94c650c6752a..bbbd680259ae69e046fc0675da6a54b2a85a87da 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UpdateFailMalformedHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFailMalformedHTLCDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(ptr);
-                       UpdateFailMalformedHTLC res_hu_conv = new UpdateFailMalformedHTLC(null, res);
+                       UpdateFailMalformedHTLC res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UpdateFailMalformedHTLC(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UpdateFailMalformedHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFailMalformedHTLCDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UpdateFailMalformedHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFailMalformedHTLCDecodeErrorZ ok(UpdateFailMalformedHTLC o) {
                long ret = bindings.CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailMalformedHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailMalformedHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UpdateFailMalformedHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFailMalformedHTLCDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailMalformedHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailMalformedHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UpdateFailMalformedHTLCDecodeErrorZ extends CommonBase {
         */
        public Result_UpdateFailMalformedHTLCDecodeErrorZ clone() {
                long ret = bindings.CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailMalformedHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailMalformedHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 91bbbb48c5f123547530e1634bda26a05664a03c..57ad26039920780047320902a0e035f82758835d 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UpdateFeeDecodeErrorZ extends CommonBase {
                private Result_UpdateFeeDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UpdateFeeDecodeErrorZ_get_ok(ptr);
-                       UpdateFee res_hu_conv = new UpdateFee(null, res);
+                       UpdateFee res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UpdateFee(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UpdateFeeDecodeErrorZ extends CommonBase {
                private Result_UpdateFeeDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UpdateFeeDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UpdateFeeDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFeeDecodeErrorZ ok(UpdateFee o) {
                long ret = bindings.CResult_UpdateFeeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UpdateFeeDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFeeDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UpdateFeeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UpdateFeeDecodeErrorZ extends CommonBase {
         */
        public Result_UpdateFeeDecodeErrorZ clone() {
                long ret = bindings.CResult_UpdateFeeDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 31f2cb93b6d1b4f11b86002676afaf6835211616..2f6e05b0d23e55ce7b2486855dda79e1560bc7df 100644 (file)
@@ -24,7 +24,7 @@ public class Result_UpdateFulfillHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFulfillHTLCDecodeErrorZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long res = bindings.LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(ptr);
-                       UpdateFulfillHTLC res_hu_conv = new UpdateFulfillHTLC(null, res);
+                       UpdateFulfillHTLC res_hu_conv = null; if (res < 0 || res > 4096) { res_hu_conv = new UpdateFulfillHTLC(null, res); }
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
@@ -35,7 +35,7 @@ public class Result_UpdateFulfillHTLCDecodeErrorZ extends CommonBase {
                private Result_UpdateFulfillHTLCDecodeErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(ptr);
-                       DecodeError err_hu_conv = new DecodeError(null, err);
+                       DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new DecodeError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -46,7 +46,7 @@ public class Result_UpdateFulfillHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFulfillHTLCDecodeErrorZ ok(UpdateFulfillHTLC o) {
                long ret = bindings.CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -56,7 +56,7 @@ public class Result_UpdateFulfillHTLCDecodeErrorZ extends CommonBase {
         */
        public static Result_UpdateFulfillHTLCDecodeErrorZ err(DecodeError e) {
                long ret = bindings.CResult_UpdateFulfillHTLCDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -67,7 +67,7 @@ public class Result_UpdateFulfillHTLCDecodeErrorZ extends CommonBase {
         */
        public Result_UpdateFulfillHTLCDecodeErrorZ clone() {
                long ret = bindings.CResult_UpdateFulfillHTLCDecodeErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index a0a3a22f2d2e6e708cf61ba9aff733376814b8b6..46a091aa5a4dd68c23d6c65b3b18cf17b77894aa 100644 (file)
@@ -43,7 +43,7 @@ public class Result__u832APIErrorZ extends CommonBase {
         */
        public static Result__u832APIErrorZ ok(byte[] o) {
                long ret = bindings.CResult__u832APIErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result__u832APIErrorZ extends CommonBase {
         */
        public static Result__u832APIErrorZ err(APIError e) {
                long ret = bindings.CResult__u832APIErrorZ_err(e.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result__u832APIErrorZ extends CommonBase {
         */
        public Result__u832APIErrorZ clone() {
                long ret = bindings.CResult__u832APIErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9d7a35957597a097cb09dd17a8ce9be4d059c4da..b2d4b1902f7d0299d646dbf15b07c09cc848b6d3 100644 (file)
@@ -32,7 +32,7 @@ public class Result_boolLightningErrorZ extends CommonBase {
                private Result_boolLightningErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_boolLightningErrorZ_get_err(ptr);
-                       LightningError err_hu_conv = new LightningError(null, err);
+                       LightningError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new LightningError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_boolLightningErrorZ extends CommonBase {
         */
        public static Result_boolLightningErrorZ ok(boolean o) {
                long ret = bindings.CResult_boolLightningErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_boolLightningErrorZ extends CommonBase {
         */
        public static Result_boolLightningErrorZ err(LightningError e) {
                long ret = bindings.CResult_boolLightningErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_boolLightningErrorZ extends CommonBase {
         */
        public Result_boolLightningErrorZ clone() {
                long ret = bindings.CResult_boolLightningErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 77b2b33a9262b525d58baec80f0464e604441e6e..d6c64887e77e7a4b06ca100d630e3bdf09fab69f 100644 (file)
@@ -32,7 +32,7 @@ public class Result_boolPeerHandleErrorZ extends CommonBase {
                private Result_boolPeerHandleErrorZ_Err(Object _dummy, long ptr) {
                        super(_dummy, ptr);
                        long err = bindings.LDKCResult_boolPeerHandleErrorZ_get_err(ptr);
-                       PeerHandleError err_hu_conv = new PeerHandleError(null, err);
+                       PeerHandleError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new PeerHandleError(null, err); }
                        err_hu_conv.ptrs_to.add(this);
                        this.err = err_hu_conv;
                }
@@ -43,7 +43,7 @@ public class Result_boolPeerHandleErrorZ extends CommonBase {
         */
        public static Result_boolPeerHandleErrorZ ok(boolean o) {
                long ret = bindings.CResult_boolPeerHandleErrorZ_ok(o);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class Result_boolPeerHandleErrorZ extends CommonBase {
         */
        public static Result_boolPeerHandleErrorZ err(PeerHandleError e) {
                long ret = bindings.CResult_boolPeerHandleErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -64,7 +64,7 @@ public class Result_boolPeerHandleErrorZ extends CommonBase {
         */
        public Result_boolPeerHandleErrorZ clone() {
                long ret = bindings.CResult_boolPeerHandleErrorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/RetryAttempts.java b/src/main/java/org/ldk/structs/RetryAttempts.java
new file mode 100644 (file)
index 0000000..fd1eb21
--- /dev/null
@@ -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;
+
+
+/**
+ * Number of attempts to retry payment path failures for an [`Invoice`].
+ * 
+ * Note that this is the number of *path* failures, not full payment retries. For multi-path
+ * payments, if this is less than the total number of paths, we will never even retry all of the
+ * payment's paths.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class RetryAttempts extends CommonBase {
+       RetryAttempts(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.RetryAttempts_free(ptr); }
+       }
+
+       public long get_a() {
+               long ret = bindings.RetryAttempts_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(long val) {
+               bindings.RetryAttempts_set_a(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new RetryAttempts given each field
+        */
+       public static RetryAttempts of(long a_arg) {
+               long ret = bindings.RetryAttempts_new(a_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RetryAttempts ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RetryAttempts(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a copy of the RetryAttempts
+        */
+       public RetryAttempts clone() {
+               long ret = bindings.RetryAttempts_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RetryAttempts ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RetryAttempts(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Checks if two RetryAttemptss 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(RetryAttempts b) {
+               boolean ret = bindings.RetryAttempts_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+       /**
+        * Checks if two RetryAttemptss contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.RetryAttempts_hash(this.ptr);
+               return ret;
+       }
+
+}
index 4e66f4d7a1fbb039dd246791103565a373713385..8ab6e5b7639026d1fd98b64e9ad5b2b1da07ca1e 100644 (file)
@@ -69,8 +69,8 @@ public class RevokeAndACK extends CommonBase {
         */
        public static RevokeAndACK of(byte[] channel_id_arg, byte[] per_commitment_secret_arg, byte[] next_per_commitment_point_arg) {
                long ret = bindings.RevokeAndACK_new(channel_id_arg, per_commitment_secret_arg, next_per_commitment_point_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RevokeAndACK ret_hu_conv = new RevokeAndACK(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RevokeAndACK(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -80,8 +80,8 @@ public class RevokeAndACK extends CommonBase {
         */
        public RevokeAndACK clone() {
                long ret = bindings.RevokeAndACK_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RevokeAndACK ret_hu_conv = new RevokeAndACK(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RevokeAndACK ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RevokeAndACK(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -99,7 +99,7 @@ public class RevokeAndACK extends CommonBase {
         */
        public static Result_RevokeAndACKDecodeErrorZ read(byte[] ser) {
                long ret = bindings.RevokeAndACK_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RevokeAndACKDecodeErrorZ ret_hu_conv = Result_RevokeAndACKDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index e0c5db9b44d0b2be2431ee12efb67c2c2c9bb057..9a7f6272b76af97a8a9c973b215c266cdf4629f6 100644 (file)
@@ -36,7 +36,7 @@ public class Route extends CommonBase {
                        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);
+                               RouteHop ret_conv_12_conv_10_hu_conv = null; if (ret_conv_12_conv_10 < 0 || ret_conv_12_conv_10 > 4096) { 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;
                        }
@@ -57,13 +57,44 @@ public class Route extends CommonBase {
                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);
        }
 
+       /**
+        * The `payee` parameter passed to [`find_route`].
+        * This is used by `ChannelManager` to track information which may be required for retries,
+        * provided back to you via [`Event::PaymentPathFailed`].
+        * 
+        * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
+        * 
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       @Nullable
+       public Payee get_payee() {
+               long ret = bindings.Route_get_payee(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * The `payee` parameter passed to [`find_route`].
+        * This is used by `ChannelManager` to track information which may be required for retries,
+        * provided back to you via [`Event::PaymentPathFailed`].
+        * 
+        * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
+        * 
+        * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       public void set_payee(@Nullable Payee val) {
+               bindings.Route_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
        /**
         * Constructs a new Route given each field
         */
-       public static Route of(RouteHop[][] paths_arg) {
-               long 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).mapToLong(paths_arg_conv_12_conv_10 -> paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr & ~1).toArray() : null).toArray(long[][]::new) : null);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Route ret_hu_conv = new Route(null, ret);
+       public static Route of(RouteHop[][] paths_arg, Payee payee_arg) {
+               long 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).mapToLong(paths_arg_conv_12_conv_10 -> paths_arg_conv_12_conv_10 == null ? 0 : paths_arg_conv_12_conv_10.ptr & ~1).toArray() : null).toArray(long[][]::new) : null, payee_arg == null ? 0 : payee_arg.ptr & ~1);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Route(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -73,8 +104,8 @@ public class Route extends CommonBase {
         */
        public Route clone() {
                long ret = bindings.Route_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Route ret_hu_conv = new Route(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Route ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Route(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -102,7 +133,7 @@ public class Route extends CommonBase {
         * 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`.
+        * the amount passed to [`find_route`]'s `params.final_value_msat`.
         */
        public long get_total_fees() {
                long ret = bindings.Route_get_total_fees(this.ptr);
@@ -130,7 +161,7 @@ public class Route extends CommonBase {
         */
        public static Result_RouteDecodeErrorZ read(byte[] ser) {
                long ret = bindings.Route_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteDecodeErrorZ ret_hu_conv = Result_RouteDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9e87ee70a739b58b3d1c654b56bd3d80b4e55d24..1b0ddef811b8e156055cf1a91c75bec8bdec11ce 100644 (file)
@@ -19,13 +19,40 @@ public class RouteHint extends CommonBase {
                if (ptr != 0) { bindings.RouteHint_free(ptr); }
        }
 
+       public RouteHintHop[] get_a() {
+               long[] ret = bindings.RouteHint_get_a(this.ptr);
+               RouteHintHop[] ret_conv_14_arr = new RouteHintHop[ret.length];
+               for (int o = 0; o < ret.length; o++) {
+                       long ret_conv_14 = ret[o];
+                       RouteHintHop ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new RouteHintHop(null, ret_conv_14); }
+                       ret_conv_14_hu_conv.ptrs_to.add(this);
+                       ret_conv_14_arr[o] = ret_conv_14_hu_conv;
+               }
+               return ret_conv_14_arr;
+       }
+
+       public void set_a(RouteHintHop[] val) {
+               bindings.RouteHint_set_a(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_14 -> val_conv_14 == null ? 0 : val_conv_14.ptr & ~1).toArray() : null);
+       }
+
+       /**
+        * Constructs a new RouteHint given each field
+        */
+       public static RouteHint of(RouteHintHop[] a_arg) {
+               long ret = bindings.RouteHint_new(a_arg != null ? Arrays.stream(a_arg).mapToLong(a_arg_conv_14 -> a_arg_conv_14 == null ? 0 : a_arg_conv_14.ptr & ~1).toArray() : null);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHint(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        /**
         * Creates a copy of the RouteHint
         */
        public RouteHint clone() {
                long ret = bindings.RouteHint_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHint ret_hu_conv = new RouteHint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -49,4 +76,22 @@ public class RouteHint extends CommonBase {
                return ret;
        }
 
+       /**
+        * Serialize the RouteHint object into a byte array which can be read by RouteHint_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.RouteHint_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a RouteHint from a byte array, created by RouteHint_write
+        */
+       public static Result_RouteHintDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.RouteHint_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
index fd5111b4e00844fcf90468f2e3ba15ec743e2bb1..86018744e02e99387810cb187d8bb09fb930c008 100644 (file)
@@ -54,8 +54,8 @@ public class RouteHintHop extends CommonBase {
         */
        public RoutingFees get_fees() {
                long ret = bindings.RouteHintHop_get_fees(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RoutingFees ret_hu_conv = new RoutingFees(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -87,7 +87,7 @@ public class RouteHintHop extends CommonBase {
         */
        public Option_u64Z get_htlc_minimum_msat() {
                long ret = bindings.RouteHintHop_get_htlc_minimum_msat(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -105,7 +105,7 @@ public class RouteHintHop extends CommonBase {
         */
        public Option_u64Z get_htlc_maximum_msat() {
                long ret = bindings.RouteHintHop_get_htlc_maximum_msat(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -123,8 +123,8 @@ public class RouteHintHop extends CommonBase {
         */
        public static RouteHintHop of(byte[] src_node_id_arg, long short_channel_id_arg, RoutingFees fees_arg, short cltv_expiry_delta_arg, Option_u64Z htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg) {
                long ret = bindings.RouteHintHop_new(src_node_id_arg, short_channel_id_arg, fees_arg == null ? 0 : fees_arg.ptr & ~1, cltv_expiry_delta_arg, htlc_minimum_msat_arg.ptr, htlc_maximum_msat_arg.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHintHop ret_hu_conv = new RouteHintHop(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHintHop(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -134,8 +134,8 @@ public class RouteHintHop extends CommonBase {
         */
        public RouteHintHop clone() {
                long ret = bindings.RouteHintHop_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHintHop ret_hu_conv = new RouteHintHop(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHintHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHintHop(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -159,4 +159,22 @@ public class RouteHintHop extends CommonBase {
                return ret;
        }
 
+       /**
+        * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.RouteHintHop_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a RouteHintHop from a byte array, created by RouteHintHop_write
+        */
+       public static Result_RouteHintHopDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.RouteHintHop_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
index 10bb9ecefb44b5b10df3fdbf709dd6b44aca31c6..59d4864652c2c65b41d921abe4b1b50b3661c7fd 100644 (file)
@@ -40,8 +40,8 @@ public class RouteHop extends CommonBase {
         */
        public NodeFeatures get_node_features() {
                long ret = bindings.RouteHop_get_node_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -75,8 +75,8 @@ public class RouteHop extends CommonBase {
         */
        public ChannelFeatures get_channel_features() {
                long ret = bindings.RouteHop_get_channel_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -130,8 +130,8 @@ public class RouteHop extends CommonBase {
         */
        public static RouteHop of(byte[] pubkey_arg, NodeFeatures node_features_arg, long short_channel_id_arg, ChannelFeatures channel_features_arg, long fee_msat_arg, int cltv_expiry_delta_arg) {
                long ret = bindings.RouteHop_new(pubkey_arg, node_features_arg == null ? 0 : node_features_arg.ptr & ~1, short_channel_id_arg, channel_features_arg == null ? 0 : channel_features_arg.ptr & ~1, fee_msat_arg, cltv_expiry_delta_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHop ret_hu_conv = new RouteHop(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -141,8 +141,8 @@ public class RouteHop extends CommonBase {
         */
        public RouteHop clone() {
                long ret = bindings.RouteHop_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RouteHop ret_hu_conv = new RouteHop(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteHop(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -179,7 +179,7 @@ public class RouteHop extends CommonBase {
         */
        public static Result_RouteHopDecodeErrorZ read(byte[] ser) {
                long ret = bindings.RouteHop_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteHopDecodeErrorZ ret_hu_conv = Result_RouteHopDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/src/main/java/org/ldk/structs/RouteParameters.java b/src/main/java/org/ldk/structs/RouteParameters.java
new file mode 100644 (file)
index 0000000..731c3a3
--- /dev/null
@@ -0,0 +1,115 @@
+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;
+
+
+/**
+ * Parameters needed to find a [`Route`] for paying a [`Payee`].
+ * 
+ * Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed
+ * payment path.
+ * 
+ * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class RouteParameters extends CommonBase {
+       RouteParameters(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.RouteParameters_free(ptr); }
+       }
+
+       /**
+        * The recipient of the failed payment path.
+        */
+       public Payee get_payee() {
+               long ret = bindings.RouteParameters_get_payee(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * The recipient of the failed payment path.
+        */
+       public void set_payee(Payee val) {
+               bindings.RouteParameters_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
+       /**
+        * The amount in msats sent on the failed payment path.
+        */
+       public long get_final_value_msat() {
+               long ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
+               return ret;
+       }
+
+       /**
+        * The amount in msats sent on the failed payment path.
+        */
+       public void set_final_value_msat(long val) {
+               bindings.RouteParameters_set_final_value_msat(this.ptr, val);
+       }
+
+       /**
+        * The CLTV on the final hop of the failed payment path.
+        */
+       public int get_final_cltv_expiry_delta() {
+               int ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr);
+               return ret;
+       }
+
+       /**
+        * The CLTV on the final hop of the failed payment path.
+        */
+       public void set_final_cltv_expiry_delta(int val) {
+               bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new RouteParameters given each field
+        */
+       public static RouteParameters of(Payee payee_arg, long final_value_msat_arg, int final_cltv_expiry_delta_arg) {
+               long ret = bindings.RouteParameters_new(payee_arg == null ? 0 : payee_arg.ptr & ~1, final_value_msat_arg, final_cltv_expiry_delta_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteParameters(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a copy of the RouteParameters
+        */
+       public RouteParameters clone() {
+               long ret = bindings.RouteParameters_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RouteParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RouteParameters(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.RouteParameters_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a RouteParameters from a byte array, created by RouteParameters_write
+        */
+       public static Result_RouteParametersDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.RouteParameters_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/src/main/java/org/ldk/structs/Router.java b/src/main/java/org/ldk/structs/Router.java
new file mode 100644 (file)
index 0000000..4174246
--- /dev/null
@@ -0,0 +1,71 @@
+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 trait defining behavior for routing an [`Invoice`] payment.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class Router extends CommonBase {
+       final bindings.LDKRouter bindings_instance;
+       Router(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
+       private Router(bindings.LDKRouter arg) {
+               super(bindings.LDKRouter_new(arg));
+               this.ptrs_to.add(arg);
+               this.bindings_instance = arg;
+       }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.Router_free(ptr); } super.finalize();
+       }
+
+       public static interface RouterInterface {
+               /**
+                * Finds a [`Route`] between `payer` and `payee` for a payment with the given values.
+                * 
+                * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
+                */
+               Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer);
+       }
+       private static class LDKRouterHolder { Router held; }
+       public static Router new_impl(RouterInterface arg) {
+               final LDKRouterHolder impl_holder = new LDKRouterHolder();
+               impl_holder.held = new Router(new bindings.LDKRouter() {
+                       @Override public long find_route(byte[] payer, long params, long[] first_hops, long scorer) {
+                               RouteParameters params_hu_conv = null; if (params < 0 || params > 4096) { params_hu_conv = new RouteParameters(null, params); }
+                               ChannelDetails[] first_hops_conv_16_arr = new ChannelDetails[first_hops.length];
+                               for (int q = 0; q < first_hops.length; q++) {
+                                       long first_hops_conv_16 = first_hops[q];
+                                       ChannelDetails first_hops_conv_16_hu_conv = null; if (first_hops_conv_16 < 0 || first_hops_conv_16 > 4096) { first_hops_conv_16_hu_conv = new ChannelDetails(null, first_hops_conv_16); }
+                                       first_hops_conv_16_hu_conv.ptrs_to.add(this);
+                                       first_hops_conv_16_arr[q] = first_hops_conv_16_hu_conv;
+                               }
+                               Score ret_hu_conv = new Score(null, scorer);
+                               ret_hu_conv.ptrs_to.add(this);
+                               Result_RouteLightningErrorZ ret = arg.find_route(payer, params_hu_conv, first_hops_conv_16_arr, ret_hu_conv);
+                               long result = ret != null ? ret.ptr : 0;
+                               return result;
+                       }
+               });
+               return impl_holder.held;
+       }
+       /**
+        * Finds a [`Route`] between `payer` and `payee` for a payment with the given values.
+        * 
+        * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, @Nullable ChannelDetails[] first_hops, Score scorer) {
+               long ret = bindings.Router_find_route(this.ptr, payer, params == null ? 0 : params.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, scorer == null ? 0 : scorer.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(params);
+               for (ChannelDetails first_hops_conv_16: first_hops) { this.ptrs_to.add(first_hops_conv_16); };
+               this.ptrs_to.add(scorer);
+               return ret_hu_conv;
+       }
+
+}
index 4fd4d255574f0e43389d41969e73e2154a9adf21..2ad54fe14d110778899c4b6cd36c54f809f4fa36 100644 (file)
@@ -56,8 +56,8 @@ public class RoutingFees extends CommonBase {
         */
        public static RoutingFees of(int base_msat_arg, int proportional_millionths_arg) {
                long ret = bindings.RoutingFees_new(base_msat_arg, proportional_millionths_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RoutingFees ret_hu_conv = new RoutingFees(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -78,8 +78,8 @@ public class RoutingFees extends CommonBase {
         */
        public RoutingFees clone() {
                long ret = bindings.RoutingFees_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RoutingFees ret_hu_conv = new RoutingFees(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -105,7 +105,7 @@ public class RoutingFees extends CommonBase {
         */
        public static Result_RoutingFeesDecodeErrorZ read(byte[] ser) {
                long ret = bindings.RoutingFees_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RoutingFeesDecodeErrorZ ret_hu_conv = Result_RoutingFeesDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c16d0bd96a0ef0a6006dbe7212fafa143476533b..eb6198717c4e1ac1a1070ab8a77ed2d00f4df30c 100644 (file)
@@ -96,19 +96,19 @@ public class RoutingMessageHandler extends CommonBase {
                final LDKRoutingMessageHandlerHolder impl_holder = new LDKRoutingMessageHandlerHolder();
                impl_holder.held = new RoutingMessageHandler(new bindings.LDKRoutingMessageHandler() {
                        @Override public long handle_node_announcement(long msg) {
-                               NodeAnnouncement msg_hu_conv = new NodeAnnouncement(null, msg);
+                               NodeAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new NodeAnnouncement(null, msg); }
                                Result_boolLightningErrorZ ret = arg.handle_node_announcement(msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long handle_channel_announcement(long msg) {
-                               ChannelAnnouncement msg_hu_conv = new ChannelAnnouncement(null, msg);
+                               ChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelAnnouncement(null, msg); }
                                Result_boolLightningErrorZ ret = arg.handle_channel_announcement(msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long handle_channel_update(long msg) {
-                               ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
+                               ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); }
                                Result_boolLightningErrorZ ret = arg.handle_channel_update(msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
@@ -124,32 +124,32 @@ public class RoutingMessageHandler extends CommonBase {
                                return result;
                        }
                        @Override public void sync_routing_table(byte[] their_node_id, long init) {
-                               Init init_hu_conv = new Init(null, init);
+                               Init init_hu_conv = null; if (init < 0 || init > 4096) { init_hu_conv = new Init(null, init); }
                                arg.sync_routing_table(their_node_id, init_hu_conv);
                        }
                        @Override public long handle_reply_channel_range(byte[] their_node_id, long msg) {
-                               ReplyChannelRange msg_hu_conv = new ReplyChannelRange(null, msg);
+                               ReplyChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ReplyChannelRange(null, msg); }
                                msg_hu_conv.ptrs_to.add(this);
                                Result_NoneLightningErrorZ ret = arg.handle_reply_channel_range(their_node_id, msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long handle_reply_short_channel_ids_end(byte[] their_node_id, long msg) {
-                               ReplyShortChannelIdsEnd msg_hu_conv = new ReplyShortChannelIdsEnd(null, msg);
+                               ReplyShortChannelIdsEnd msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ReplyShortChannelIdsEnd(null, msg); }
                                msg_hu_conv.ptrs_to.add(this);
                                Result_NoneLightningErrorZ ret = arg.handle_reply_short_channel_ids_end(their_node_id, msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long handle_query_channel_range(byte[] their_node_id, long msg) {
-                               QueryChannelRange msg_hu_conv = new QueryChannelRange(null, msg);
+                               QueryChannelRange msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryChannelRange(null, msg); }
                                msg_hu_conv.ptrs_to.add(this);
                                Result_NoneLightningErrorZ ret = arg.handle_query_channel_range(their_node_id, msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long handle_query_short_channel_ids(byte[] their_node_id, long msg) {
-                               QueryShortChannelIds msg_hu_conv = new QueryShortChannelIds(null, msg);
+                               QueryShortChannelIds msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new QueryShortChannelIds(null, msg); }
                                msg_hu_conv.ptrs_to.add(this);
                                Result_NoneLightningErrorZ ret = arg.handle_query_short_channel_ids(their_node_id, msg_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
@@ -174,7 +174,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_boolLightningErrorZ handle_node_announcement(NodeAnnouncement msg) {
                long ret = bindings.RoutingMessageHandler_handle_node_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -186,7 +186,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_boolLightningErrorZ handle_channel_announcement(ChannelAnnouncement msg) {
                long ret = bindings.RoutingMessageHandler_handle_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -198,7 +198,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_boolLightningErrorZ handle_channel_update(ChannelUpdate msg) {
                long ret = bindings.RoutingMessageHandler_handle_channel_update(this.ptr, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
                this.ptrs_to.add(msg);
                return ret_hu_conv;
@@ -234,7 +234,7 @@ public class RoutingMessageHandler extends CommonBase {
                NodeAnnouncement[] ret_conv_18_arr = new NodeAnnouncement[ret.length];
                for (int s = 0; s < ret.length; s++) {
                        long ret_conv_18 = ret[s];
-                       NodeAnnouncement ret_conv_18_hu_conv = new NodeAnnouncement(null, ret_conv_18);
+                       NodeAnnouncement ret_conv_18_hu_conv = null; if (ret_conv_18 < 0 || ret_conv_18 > 4096) { ret_conv_18_hu_conv = new NodeAnnouncement(null, ret_conv_18); }
                        ret_conv_18_hu_conv.ptrs_to.add(this);
                        ret_conv_18_arr[s] = ret_conv_18_hu_conv;
                }
@@ -258,7 +258,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_NoneLightningErrorZ handle_reply_channel_range(byte[] their_node_id, ReplyChannelRange msg) {
                long ret = bindings.RoutingMessageHandler_handle_reply_channel_range(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -271,7 +271,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_NoneLightningErrorZ handle_reply_short_channel_ids_end(byte[] their_node_id, ReplyShortChannelIdsEnd msg) {
                long ret = bindings.RoutingMessageHandler_handle_reply_short_channel_ids_end(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -282,7 +282,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_NoneLightningErrorZ handle_query_channel_range(byte[] their_node_id, QueryChannelRange msg) {
                long ret = bindings.RoutingMessageHandler_handle_query_channel_range(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -293,7 +293,7 @@ public class RoutingMessageHandler extends CommonBase {
         */
        public Result_NoneLightningErrorZ handle_query_short_channel_ids(byte[] their_node_id, QueryShortChannelIds msg) {
                long ret = bindings.RoutingMessageHandler_handle_query_short_channel_ids(this.ptr, their_node_id, msg == null ? 0 : msg.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index f7a0d95e9a229a20cb6c5e0cd5659ad340763c9d..902dc021d3a2ff3e18afee0f70957b43fd8dfa25 100644 (file)
@@ -27,26 +27,69 @@ public class Score extends CommonBase {
 
        public static interface ScoreInterface {
                /**
-                * Returns the fee in msats willing to be paid to avoid routing through the given channel.
+                * Returns the fee in msats willing to be paid to avoid routing through the given channel
+                * in the direction from `source` to `target`.
                 */
-               long channel_penalty_msat(long short_channel_id);
+               long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target);
+               /**
+                * Handles updating channel penalties after failing to route through a channel.
+                */
+               void payment_path_failed(RouteHop[] path, long short_channel_id);
+               /**
+                * Serialize the object into a byte array
+                */
+               byte[] write();
        }
        private static class LDKScoreHolder { Score held; }
        public static Score new_impl(ScoreInterface arg) {
                final LDKScoreHolder impl_holder = new LDKScoreHolder();
                impl_holder.held = new Score(new bindings.LDKScore() {
-                       @Override public long channel_penalty_msat(long short_channel_id) {
-                               long ret = arg.channel_penalty_msat(short_channel_id);
+                       @Override public long channel_penalty_msat(long short_channel_id, long source, long target) {
+                               NodeId source_hu_conv = null; if (source < 0 || source > 4096) { source_hu_conv = new NodeId(null, source); }
+                               NodeId target_hu_conv = null; if (target < 0 || target > 4096) { target_hu_conv = new NodeId(null, target); }
+                               long ret = arg.channel_penalty_msat(short_channel_id, source_hu_conv, target_hu_conv);
+                               return ret;
+                       }
+                       @Override public void payment_path_failed(long[] path, long short_channel_id) {
+                               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 = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { 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;
+                               }
+                               arg.payment_path_failed(path_conv_10_arr, short_channel_id);
+                       }
+                       @Override public byte[] write() {
+                               byte[] ret = arg.write();
                                return ret;
                        }
                });
                return impl_holder.held;
        }
        /**
-        * Returns the fee in msats willing to be paid to avoid routing through the given channel.
+        * Returns the fee in msats willing to be paid to avoid routing through the given channel
+        * in the direction from `source` to `target`.
+        */
+       public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target) {
+               long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, source == null ? 0 : source.ptr & ~1, target == null ? 0 : target.ptr & ~1);
+               this.ptrs_to.add(source);
+               this.ptrs_to.add(target);
+               return ret;
+       }
+
+       /**
+        * Handles updating channel penalties after failing to route through a channel.
+        */
+       public void payment_path_failed(RouteHop[] path, long short_channel_id) {
+               bindings.Score_payment_path_failed(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null, short_channel_id);
+       }
+
+       /**
+        * Serialize the object into a byte array
         */
-       public long channel_penalty_msat(long short_channel_id) {
-               long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id);
+       public byte[] write() {
+               byte[] ret = bindings.Score_write(this.ptr);
                return ret;
        }
 
index f1f8ecd548f029d5ece646b7fe9b0713098898fe..82b995792a6aad588ff985b57ef25f57265ffc32 100644 (file)
@@ -11,7 +11,7 @@ import javax.annotation.Nullable;
  * [`routing::Score`] implementation that provides reasonable default behavior.
  * 
  * Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with
- * slightly higher fees are available.
+ * slightly higher fees are available. Will further penalize channels that fail to relay payments.
  * 
  * See [module-level documentation] for usage.
  * 
@@ -27,12 +27,12 @@ public class Scorer extends CommonBase {
        }
 
        /**
-        * Creates a new scorer using `base_penalty_msat` as the channel penalty.
+        * Creates a new scorer using the given scoring parameters.
         */
-       public static Scorer of(long base_penalty_msat) {
-               long ret = bindings.Scorer_new(base_penalty_msat);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Scorer ret_hu_conv = new Scorer(null, ret);
+       public static Scorer of(long params_base_penalty_msat_arg, long params_failure_penalty_msat_arg, long params_failure_penalty_half_life_arg) {
+               long ret = bindings.Scorer_new(bindings.ScoringParameters_new(params_base_penalty_msat_arg, params_failure_penalty_msat_arg, params_failure_penalty_half_life_arg));
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Scorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Scorer(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -42,8 +42,8 @@ public class Scorer extends CommonBase {
         */
        public static Scorer with_default() {
                long ret = bindings.Scorer_default();
-               if (ret >= 0 && ret < 1024) { return null; }
-               Scorer ret_hu_conv = new Scorer(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Scorer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Scorer(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -54,10 +54,28 @@ public class Scorer extends CommonBase {
         */
        public Score as_Score() {
                long ret = bindings.Scorer_as_Score(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Score ret_hu_conv = new Score(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
 
+       /**
+        * Serialize the Scorer object into a byte array which can be read by Scorer_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.Scorer_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a Scorer from a byte array, created by Scorer_write
+        */
+       public static Result_ScorerDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.Scorer_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_ScorerDecodeErrorZ ret_hu_conv = Result_ScorerDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
diff --git a/src/main/java/org/ldk/structs/ScoringParameters.java b/src/main/java/org/ldk/structs/ScoringParameters.java
new file mode 100644 (file)
index 0000000..eccd438
--- /dev/null
@@ -0,0 +1,133 @@
+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;
+
+
+/**
+ * Parameters for configuring [`Scorer`].
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class ScoringParameters extends CommonBase {
+       ScoringParameters(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.ScoringParameters_free(ptr); }
+       }
+
+       /**
+        * A fixed penalty in msats to apply to each channel.
+        */
+       public long get_base_penalty_msat() {
+               long ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr);
+               return ret;
+       }
+
+       /**
+        * A fixed penalty in msats to apply to each channel.
+        */
+       public void set_base_penalty_msat(long val) {
+               bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val);
+       }
+
+       /**
+        * A penalty in msats to apply to a channel upon failing to relay a payment.
+        * 
+        * This accumulates for each failure but may be reduced over time based on
+        * [`failure_penalty_half_life`].
+        * 
+        * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
+        */
+       public long get_failure_penalty_msat() {
+               long ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr);
+               return ret;
+       }
+
+       /**
+        * A penalty in msats to apply to a channel upon failing to relay a payment.
+        * 
+        * This accumulates for each failure but may be reduced over time based on
+        * [`failure_penalty_half_life`].
+        * 
+        * [`failure_penalty_half_life`]: Self::failure_penalty_half_life
+        */
+       public void set_failure_penalty_msat(long val) {
+               bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val);
+       }
+
+       /**
+        * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
+        * cut in half.
+        * 
+        * # Note
+        * 
+        * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
+        * elapse. Therefore, this penalty will never decay.
+        * 
+        * [`failure_penalty_msat`]: Self::failure_penalty_msat
+        */
+       public long get_failure_penalty_half_life() {
+               long ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr);
+               return ret;
+       }
+
+       /**
+        * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are
+        * cut in half.
+        * 
+        * # Note
+        * 
+        * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never
+        * elapse. Therefore, this penalty will never decay.
+        * 
+        * [`failure_penalty_msat`]: Self::failure_penalty_msat
+        */
+       public void set_failure_penalty_half_life(long val) {
+               bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val);
+       }
+
+       /**
+        * Constructs a new ScoringParameters given each field
+        */
+       public static ScoringParameters of(long base_penalty_msat_arg, long failure_penalty_msat_arg, long failure_penalty_half_life_arg) {
+               long ret = bindings.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.ScoringParameters_write(this.ptr);
+               return ret;
+       }
+
+       /**
+        * Read a ScoringParameters from a byte array, created by ScoringParameters_write
+        */
+       public static Result_ScoringParametersDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.ScoringParameters_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a "default" ScoringParameters. See struct and individual field documentaiton for details on which values are used.
+        */
+       public static ScoringParameters with_default() {
+               long ret = bindings.ScoringParameters_default();
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ScoringParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ScoringParameters(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+}
index 4cdcbf79895e7ddb1d4851125d1b2c831730ccd4..47a2cae6b40790d89beca623a6a1983fa93dc726 100644 (file)
@@ -24,8 +24,8 @@ public class Sha256 extends CommonBase {
         */
        public Sha256 clone() {
                long ret = bindings.Sha256_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Sha256 ret_hu_conv = new Sha256(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 187027b436a832014bd7dfeb2b54a91b974ddd5a..4c0e6f4886395cf4c4697c8ff72c970da1690ebe 100644 (file)
@@ -56,8 +56,8 @@ public class Shutdown extends CommonBase {
         */
        public static Shutdown of(byte[] channel_id_arg, byte[] scriptpubkey_arg) {
                long ret = bindings.Shutdown_new(channel_id_arg, scriptpubkey_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Shutdown ret_hu_conv = new Shutdown(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -67,8 +67,8 @@ public class Shutdown extends CommonBase {
         */
        public Shutdown clone() {
                long ret = bindings.Shutdown_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Shutdown ret_hu_conv = new Shutdown(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Shutdown ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Shutdown(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -86,7 +86,7 @@ public class Shutdown extends CommonBase {
         */
        public static Result_ShutdownDecodeErrorZ read(byte[] ser) {
                long ret = bindings.Shutdown_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownDecodeErrorZ ret_hu_conv = Result_ShutdownDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 5d19017c52e58f613164d46a6f9072d3d08ad1e8..19a81ae000754325750b38a23501674b1315342a 100644 (file)
@@ -26,8 +26,8 @@ public class ShutdownScript extends CommonBase {
         */
        public ShutdownScript clone() {
                long ret = bindings.ShutdownScript_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ShutdownScript ret_hu_conv = new ShutdownScript(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -45,7 +45,7 @@ public class ShutdownScript extends CommonBase {
         */
        public static Result_ShutdownScriptDecodeErrorZ read(byte[] ser) {
                long ret = bindings.ShutdownScript_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptDecodeErrorZ ret_hu_conv = Result_ShutdownScriptDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -55,8 +55,8 @@ public class ShutdownScript extends CommonBase {
         */
        public static ShutdownScript new_p2wpkh(byte[] pubkey_hash) {
                long ret = bindings.ShutdownScript_new_p2wpkh(pubkey_hash);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ShutdownScript ret_hu_conv = new ShutdownScript(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -66,8 +66,8 @@ public class ShutdownScript extends CommonBase {
         */
        public static ShutdownScript new_p2wsh(byte[] script_hash) {
                long ret = bindings.ShutdownScript_new_p2wsh(script_hash);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ShutdownScript ret_hu_conv = new ShutdownScript(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -84,7 +84,7 @@ public class ShutdownScript extends CommonBase {
         */
        public static Result_ShutdownScriptInvalidShutdownScriptZ new_witness_program(byte version, byte[] program) {
                long ret = bindings.ShutdownScript_new_witness_program(version, program);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 48268cdeb342cbcdb771d72cd3a871036a647ff6..5a0221581937b7c8d92053669fecff5c017de6ed 100644 (file)
@@ -68,7 +68,7 @@ public class Sign extends CommonBase {
         */
        public Sign clone() {
                long ret = bindings.Sign_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Sign ret_hu_conv = new Sign(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 2508cb42737680b619f117fe06d43b2d12ce8b7e..8273e9b157ff26766dba334d8ef3e4772aea4ab7 100644 (file)
@@ -47,7 +47,7 @@ public class SignOrCreationError extends CommonBase {
         */
        public SignOrCreationError clone() {
                long ret = bindings.SignOrCreationError_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -58,7 +58,7 @@ public class SignOrCreationError extends CommonBase {
         */
        public static SignOrCreationError sign_error() {
                long ret = bindings.SignOrCreationError_sign_error();
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -69,7 +69,7 @@ public class SignOrCreationError extends CommonBase {
         */
        public static SignOrCreationError creation_error(org.ldk.enums.CreationError a) {
                long ret = bindings.SignOrCreationError_creation_error(a);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 048cac3b6a7d687677b0db0c4209d99cce42cba6..0b976307005baeb9fda4cee407b5ace4bc506a13 100644 (file)
@@ -39,8 +39,8 @@ public class SignedRawInvoice extends CommonBase {
         */
        public SignedRawInvoice clone() {
                long ret = bindings.SignedRawInvoice_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               SignedRawInvoice ret_hu_conv = new SignedRawInvoice(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new SignedRawInvoice(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -53,7 +53,7 @@ public class SignedRawInvoice extends CommonBase {
         */
        public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() {
                long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                ;
@@ -65,8 +65,8 @@ public class SignedRawInvoice extends CommonBase {
         */
        public RawInvoice raw_invoice() {
                long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               RawInvoice ret_hu_conv = new RawInvoice(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,8 +84,8 @@ public class SignedRawInvoice extends CommonBase {
         */
        public InvoiceSignature signature() {
                long ret = bindings.SignedRawInvoice_signature(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               InvoiceSignature ret_hu_conv = new InvoiceSignature(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceSignature(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -95,7 +95,7 @@ public class SignedRawInvoice extends CommonBase {
         */
        public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
                long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -114,7 +114,7 @@ public class SignedRawInvoice extends CommonBase {
         */
        public static Result_SignedRawInvoiceNoneZ from_str(java.lang.String s) {
                long ret = bindings.SignedRawInvoice_from_str(s);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index fd8454c7509286596287ec4e33a1e3edf5796b98..ae23786d56b45bcd74294782f2ece41db83d22d5 100644 (file)
@@ -144,7 +144,7 @@ public class SocketDescriptor extends CommonBase {
         */
        public SocketDescriptor clone() {
                long ret = bindings.SocketDescriptor_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index 01a179580f094a500f63393a1af414907833eb0f..236a33fe07d50fd25322a433db75599bff417dcc 100644 (file)
@@ -48,7 +48,7 @@ public class SpendableOutputDescriptor extends CommonBase {
                private StaticOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticOutput obj) {
                        super(null, ptr);
                        long outpoint = obj.outpoint;
-                       OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
+                       OutPoint outpoint_hu_conv = null; if (outpoint < 0 || outpoint > 4096) { outpoint_hu_conv = new OutPoint(null, outpoint); }
                        outpoint_hu_conv.ptrs_to.add(this);
                        this.outpoint = outpoint_hu_conv;
                        long output = obj.output;
@@ -61,7 +61,7 @@ public class SpendableOutputDescriptor extends CommonBase {
                private DelayedPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.DelayedPaymentOutput obj) {
                        super(null, ptr);
                        long delayed_payment_output = obj.delayed_payment_output;
-                       DelayedPaymentOutputDescriptor delayed_payment_output_hu_conv = new DelayedPaymentOutputDescriptor(null, delayed_payment_output);
+                       DelayedPaymentOutputDescriptor delayed_payment_output_hu_conv = null; if (delayed_payment_output < 0 || delayed_payment_output > 4096) { delayed_payment_output_hu_conv = new DelayedPaymentOutputDescriptor(null, delayed_payment_output); }
                        delayed_payment_output_hu_conv.ptrs_to.add(this);
                        this.delayed_payment_output = delayed_payment_output_hu_conv;
                }
@@ -71,7 +71,7 @@ public class SpendableOutputDescriptor extends CommonBase {
                private StaticPaymentOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticPaymentOutput obj) {
                        super(null, ptr);
                        long static_payment_output = obj.static_payment_output;
-                       StaticPaymentOutputDescriptor static_payment_output_hu_conv = new StaticPaymentOutputDescriptor(null, static_payment_output);
+                       StaticPaymentOutputDescriptor static_payment_output_hu_conv = null; if (static_payment_output < 0 || static_payment_output > 4096) { static_payment_output_hu_conv = new StaticPaymentOutputDescriptor(null, static_payment_output); }
                        static_payment_output_hu_conv.ptrs_to.add(this);
                        this.static_payment_output = static_payment_output_hu_conv;
                }
@@ -81,7 +81,7 @@ public class SpendableOutputDescriptor extends CommonBase {
         */
        public SpendableOutputDescriptor clone() {
                long ret = bindings.SpendableOutputDescriptor_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -92,7 +92,7 @@ public class SpendableOutputDescriptor extends CommonBase {
         */
        public static SpendableOutputDescriptor static_output(OutPoint outpoint, TxOut output) {
                long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr & ~1, output.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -103,7 +103,7 @@ public class SpendableOutputDescriptor extends CommonBase {
         */
        public static SpendableOutputDescriptor delayed_payment_output(DelayedPaymentOutputDescriptor a) {
                long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a == null ? 0 : a.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -114,7 +114,7 @@ public class SpendableOutputDescriptor extends CommonBase {
         */
        public static SpendableOutputDescriptor static_payment_output(StaticPaymentOutputDescriptor a) {
                long ret = bindings.SpendableOutputDescriptor_static_payment_output(a == null ? 0 : a.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                SpendableOutputDescriptor ret_hu_conv = SpendableOutputDescriptor.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -133,7 +133,7 @@ public class SpendableOutputDescriptor extends CommonBase {
         */
        public static Result_SpendableOutputDescriptorDecodeErrorZ read(byte[] ser) {
                long ret = bindings.SpendableOutputDescriptor_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SpendableOutputDescriptorDecodeErrorZ ret_hu_conv = Result_SpendableOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 9f15a3ad435d124a94ebbd47fb042b960adcfca9..f3b4d7d43433dc78ec4b362569070fe7be52a487 100644 (file)
@@ -25,8 +25,8 @@ public class StaticPaymentOutputDescriptor extends CommonBase {
         */
        public OutPoint get_outpoint() {
                long ret = bindings.StaticPaymentOutputDescriptor_get_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,8 +84,8 @@ public class StaticPaymentOutputDescriptor extends CommonBase {
         */
        public static StaticPaymentOutputDescriptor of(OutPoint outpoint_arg, TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
                long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, output_arg.ptr, channel_keys_id_arg, channel_value_satoshis_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               StaticPaymentOutputDescriptor ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -95,8 +95,8 @@ public class StaticPaymentOutputDescriptor extends CommonBase {
         */
        public StaticPaymentOutputDescriptor clone() {
                long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               StaticPaymentOutputDescriptor ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -114,7 +114,7 @@ public class StaticPaymentOutputDescriptor extends CommonBase {
         */
        public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
                long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index f5fe67f129de2f9587f2df594305e7b15171921d..0816d27cc90f0484a8c3ea9d4fff3a2ae36417ae 100644 (file)
@@ -37,8 +37,8 @@ public class TrustedCommitmentTransaction extends CommonBase {
         */
        public BuiltCommitmentTransaction built_transaction() {
                long ret = bindings.TrustedCommitmentTransaction_built_transaction(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -48,8 +48,8 @@ public class TrustedCommitmentTransaction extends CommonBase {
         */
        public TxCreationKeys keys() {
                long ret = bindings.TrustedCommitmentTransaction_keys(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -62,7 +62,7 @@ public class TrustedCommitmentTransaction extends CommonBase {
         */
        public Result_CVec_SignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, DirectedChannelTransactionParameters channel_parameters) {
                long ret = bindings.TrustedCommitmentTransaction_get_htlc_sigs(this.ptr, htlc_base_key, channel_parameters == null ? 0 : channel_parameters.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
                this.ptrs_to.add(channel_parameters);
                return ret_hu_conv;
index f2de17661aa4e3fb11866297f6d08ecbfcaa10bc..949ac9c2ae9618696814e3b2b3736d89ea55a1d5 100644 (file)
@@ -32,8 +32,8 @@ public class TwoTuple_BlockHashChannelManagerZ extends CommonBase {
         */
        public ChannelManager get_b() {
                long ret = bindings.C2Tuple_BlockHashChannelManagerZ_get_b(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelManager ret_hu_conv = new ChannelManager(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelManager(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -43,7 +43,7 @@ public class TwoTuple_BlockHashChannelManagerZ extends CommonBase {
         */
        public static TwoTuple_BlockHashChannelManagerZ of(byte[] a, FeeEstimator b_fee_est, Watch b_chain_monitor, BroadcasterInterface b_tx_broadcaster, Logger b_logger, KeysInterface b_keys_manager, UserConfig b_config, ChainParameters b_params) {
                long ret = bindings.C2Tuple_BlockHashChannelManagerZ_new(a, bindings.ChannelManager_new(b_fee_est == null ? 0 : b_fee_est.ptr, b_chain_monitor == null ? 0 : b_chain_monitor.ptr, b_tx_broadcaster == null ? 0 : b_tx_broadcaster.ptr, b_logger == null ? 0 : b_logger.ptr, b_keys_manager == null ? 0 : b_keys_manager.ptr, b_config == null ? 0 : b_config.ptr & ~1, b_params == null ? 0 : b_params.ptr & ~1));
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_BlockHashChannelManagerZ ret_hu_conv = new TwoTuple_BlockHashChannelManagerZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(b_fee_est);
index c3e897ca8753ecd09971bd0a4568b9933ea95414..5f15308731bb0bf4846a508d53bda2b0888336e8 100644 (file)
@@ -32,8 +32,8 @@ public class TwoTuple_BlockHashChannelMonitorZ extends CommonBase {
         */
        public ChannelMonitor get_b() {
                long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_get_b(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelMonitor ret_hu_conv = new ChannelMonitor(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelMonitor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelMonitor(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -44,7 +44,7 @@ public class TwoTuple_BlockHashChannelMonitorZ extends CommonBase {
         */
        public TwoTuple_BlockHashChannelMonitorZ clone() {
                long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_BlockHashChannelMonitorZ ret_hu_conv = new TwoTuple_BlockHashChannelMonitorZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -55,7 +55,7 @@ public class TwoTuple_BlockHashChannelMonitorZ extends CommonBase {
         */
        public static TwoTuple_BlockHashChannelMonitorZ of(byte[] a, ChannelMonitor b) {
                long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_new(a, b == null ? 0 : b.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_BlockHashChannelMonitorZ ret_hu_conv = new TwoTuple_BlockHashChannelMonitorZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index a63afed274ab0298e7d88fcfb514de4b14aa67ae..d0582880f73c61d0c24351e13e8c22fb7f2d150f 100644 (file)
@@ -24,8 +24,8 @@ public class TwoTuple_OutPointScriptZ extends CommonBase {
         */
        public OutPoint get_a() {
                long ret = bindings.C2Tuple_OutPointScriptZ_get_a(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -44,7 +44,7 @@ public class TwoTuple_OutPointScriptZ extends CommonBase {
         */
        public TwoTuple_OutPointScriptZ clone() {
                long ret = bindings.C2Tuple_OutPointScriptZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_OutPointScriptZ ret_hu_conv = new TwoTuple_OutPointScriptZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -55,7 +55,7 @@ public class TwoTuple_OutPointScriptZ extends CommonBase {
         */
        public static TwoTuple_OutPointScriptZ of(OutPoint a, byte[] b) {
                long ret = bindings.C2Tuple_OutPointScriptZ_new(a == null ? 0 : a.ptr & ~1, b);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_OutPointScriptZ ret_hu_conv = new TwoTuple_OutPointScriptZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 3d8845b219d606a65accabf660e95895833e8046..2f1cadedbf670a4aa12a147b69eb02b7d4ab2e02 100644 (file)
@@ -30,12 +30,9 @@ public class TwoTuple_PaymentHashPaymentIdZ extends CommonBase {
        /**
         * 
         */
-       public PaymentId get_b() {
-               long ret = bindings.C2Tuple_PaymentHashPaymentIdZ_get_b(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               PaymentId ret_hu_conv = new PaymentId(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
+       public byte[] get_b() {
+               byte[] ret = bindings.C2Tuple_PaymentHashPaymentIdZ_get_b(this.ptr);
+               return ret;
        }
 
        /**
@@ -44,7 +41,7 @@ public class TwoTuple_PaymentHashPaymentIdZ extends CommonBase {
         */
        public TwoTuple_PaymentHashPaymentIdZ clone() {
                long ret = bindings.C2Tuple_PaymentHashPaymentIdZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PaymentHashPaymentIdZ ret_hu_conv = new TwoTuple_PaymentHashPaymentIdZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -53,9 +50,9 @@ public class TwoTuple_PaymentHashPaymentIdZ extends CommonBase {
        /**
         * Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements.
         */
-       public static TwoTuple_PaymentHashPaymentIdZ of(byte[] a, PaymentId b) {
-               long ret = bindings.C2Tuple_PaymentHashPaymentIdZ_new(a, b == null ? 0 : b.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static TwoTuple_PaymentHashPaymentIdZ of(byte[] a, byte[] b) {
+               long ret = bindings.C2Tuple_PaymentHashPaymentIdZ_new(a, b);
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PaymentHashPaymentIdZ ret_hu_conv = new TwoTuple_PaymentHashPaymentIdZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 1a1975299130f53aecc58c0b5737b6f24f641485..0ba6ac805f5ee6efdb4935f4e2dd33278541ba0c 100644 (file)
@@ -41,7 +41,7 @@ public class TwoTuple_PaymentHashPaymentSecretZ extends CommonBase {
         */
        public TwoTuple_PaymentHashPaymentSecretZ clone() {
                long ret = bindings.C2Tuple_PaymentHashPaymentSecretZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PaymentHashPaymentSecretZ ret_hu_conv = new TwoTuple_PaymentHashPaymentSecretZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -52,7 +52,7 @@ public class TwoTuple_PaymentHashPaymentSecretZ extends CommonBase {
         */
        public static TwoTuple_PaymentHashPaymentSecretZ of(byte[] a, byte[] b) {
                long ret = bindings.C2Tuple_PaymentHashPaymentSecretZ_new(a, b);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PaymentHashPaymentSecretZ ret_hu_conv = new TwoTuple_PaymentHashPaymentSecretZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index baf3eeb7228d09f83070b38a1b8389e55c4fe4f5..90a42ae8fe69658c754df74e26c55d16a2c3ad2b 100644 (file)
@@ -32,7 +32,7 @@ public class TwoTuple_PublicKeyTypeZ extends CommonBase {
         */
        public Type get_b() {
                long ret = bindings.C2Tuple_PublicKeyTypeZ_get_b(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Type ret_hu_conv = new Type(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -44,7 +44,7 @@ public class TwoTuple_PublicKeyTypeZ extends CommonBase {
         */
        public TwoTuple_PublicKeyTypeZ clone() {
                long ret = bindings.C2Tuple_PublicKeyTypeZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PublicKeyTypeZ ret_hu_conv = new TwoTuple_PublicKeyTypeZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -55,7 +55,7 @@ public class TwoTuple_PublicKeyTypeZ extends CommonBase {
         */
        public static TwoTuple_PublicKeyTypeZ of(byte[] a, Type b) {
                long ret = bindings.C2Tuple_PublicKeyTypeZ_new(a, b == null ? 0 : b.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_PublicKeyTypeZ ret_hu_conv = new TwoTuple_PublicKeyTypeZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                ret_hu_conv.ptrs_to.add(b);
index 107d0aeab956f130ed0d0d9324bf9037fb3a0e3d..3118746c7978273ddf866fc5a988e9b489c1974b 100644 (file)
@@ -41,7 +41,7 @@ public class TwoTuple_SignatureCVec_SignatureZZ extends CommonBase {
         */
        public TwoTuple_SignatureCVec_SignatureZZ clone() {
                long ret = bindings.C2Tuple_SignatureCVec_SignatureZZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_SignatureCVec_SignatureZZ ret_hu_conv = new TwoTuple_SignatureCVec_SignatureZZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -52,7 +52,7 @@ public class TwoTuple_SignatureCVec_SignatureZZ extends CommonBase {
         */
        public static TwoTuple_SignatureCVec_SignatureZZ of(byte[] a, byte[][] b) {
                long ret = bindings.C2Tuple_SignatureCVec_SignatureZZ_new(a, b);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_SignatureCVec_SignatureZZ ret_hu_conv = new TwoTuple_SignatureCVec_SignatureZZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 12e461b09d6be1e27f0032c7eb9fcf4da9b12371..6ea8960e40f52868e8a04d9ab32a48dd19734904 100644 (file)
@@ -48,7 +48,7 @@ public class TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ extends CommonBase {
         */
        public TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ clone() {
                long ret = bindings.C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ ret_hu_conv = new TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -59,7 +59,7 @@ public class TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ extends CommonBase {
         */
        public static TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ of(byte[] a, TwoTuple_u32ScriptZ[] b) {
                long ret = bindings.C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a, b != null ? Arrays.stream(b).mapToLong(b_conv_21 -> b_conv_21 != null ? b_conv_21.ptr : 0).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ ret_hu_conv = new TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 430838699aa05747b3f3cbfec10245718a3d8829..926a55b16a0de729b4fcccfee3e350ea8ba6af4e 100644 (file)
@@ -48,7 +48,7 @@ public class TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ extends CommonBase {
         */
        public TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ clone() {
                long ret = bindings.C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ ret_hu_conv = new TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -59,7 +59,7 @@ public class TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ extends CommonBase {
         */
        public static TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ of(byte[] a, TwoTuple_u32TxOutZ[] b) {
                long ret = bindings.C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a, b != null ? Arrays.stream(b).mapToLong(b_conv_20 -> b_conv_20 != null ? b_conv_20.ptr : 0).toArray() : null);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ ret_hu_conv = new TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 4097de5787545fb7d5312d5f6ffb8701290dcb25..d7c869363fac5e1d5aae6777f1218387ef9dc55f 100644 (file)
@@ -41,7 +41,7 @@ public class TwoTuple_u32ScriptZ extends CommonBase {
         */
        public TwoTuple_u32ScriptZ clone() {
                long ret = bindings.C2Tuple_u32ScriptZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_u32ScriptZ ret_hu_conv = new TwoTuple_u32ScriptZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -52,7 +52,7 @@ public class TwoTuple_u32ScriptZ extends CommonBase {
         */
        public static TwoTuple_u32ScriptZ of(int a, byte[] b) {
                long ret = bindings.C2Tuple_u32ScriptZ_new(a, b);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_u32ScriptZ ret_hu_conv = new TwoTuple_u32ScriptZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index ee5d9c96379f2b7399247a5c9d05cead2ed2ce96..fba6cad226edbc7f0869865e7e1a554e2a137316 100644 (file)
@@ -32,7 +32,7 @@ public class TwoTuple_u32TxOutZ extends CommonBase {
         */
        public TxOut get_b() {
                long ret = bindings.C2Tuple_u32TxOutZ_get_b(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TxOut ret_conv = new TxOut(null, ret);
                return ret_conv;
        }
@@ -43,7 +43,7 @@ public class TwoTuple_u32TxOutZ extends CommonBase {
         */
        public TwoTuple_u32TxOutZ clone() {
                long ret = bindings.C2Tuple_u32TxOutZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_u32TxOutZ ret_hu_conv = new TwoTuple_u32TxOutZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -54,7 +54,7 @@ public class TwoTuple_u32TxOutZ extends CommonBase {
         */
        public static TwoTuple_u32TxOutZ of(int a, TxOut b) {
                long ret = bindings.C2Tuple_u32TxOutZ_new(a, b.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_u32TxOutZ ret_hu_conv = new TwoTuple_u32TxOutZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index fd8e186cbe365692766d30363596f2aac863d957..73d02f05fad29f4a8d7da0c2bbb5aa6139f2d6a2 100644 (file)
@@ -41,7 +41,7 @@ public class TwoTuple_usizeTransactionZ extends CommonBase {
         */
        public TwoTuple_usizeTransactionZ clone() {
                long ret = bindings.C2Tuple_usizeTransactionZ_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_usizeTransactionZ ret_hu_conv = new TwoTuple_usizeTransactionZ(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
@@ -52,7 +52,7 @@ public class TwoTuple_usizeTransactionZ extends CommonBase {
         */
        public static TwoTuple_usizeTransactionZ of(long a, byte[] b) {
                long ret = bindings.C2Tuple_usizeTransactionZ_new(a, b);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                TwoTuple_usizeTransactionZ ret_hu_conv = new TwoTuple_usizeTransactionZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 54ce983191dcac4a1238e47b9971eaf814123f41..22e03cf428c886b9561bfaaa8b4e638daefcb641 100644 (file)
@@ -113,8 +113,8 @@ public class TxCreationKeys extends CommonBase {
         */
        public static TxCreationKeys of(byte[] per_commitment_point_arg, byte[] revocation_key_arg, byte[] broadcaster_htlc_key_arg, byte[] countersignatory_htlc_key_arg, byte[] broadcaster_delayed_payment_key_arg) {
                long ret = bindings.TxCreationKeys_new(per_commitment_point_arg, revocation_key_arg, broadcaster_htlc_key_arg, countersignatory_htlc_key_arg, broadcaster_delayed_payment_key_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -124,8 +124,8 @@ public class TxCreationKeys extends CommonBase {
         */
        public TxCreationKeys clone() {
                long ret = bindings.TxCreationKeys_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -143,7 +143,7 @@ public class TxCreationKeys extends CommonBase {
         */
        public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
                long ret = bindings.TxCreationKeys_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -154,7 +154,7 @@ public class TxCreationKeys extends CommonBase {
         */
        public static Result_TxCreationKeysErrorZ derive_new(byte[] per_commitment_point, byte[] broadcaster_delayed_payment_base, byte[] broadcaster_htlc_base, byte[] countersignatory_revocation_base, byte[] countersignatory_htlc_base) {
                long ret = bindings.TxCreationKeys_derive_new(per_commitment_point, broadcaster_delayed_payment_base, broadcaster_htlc_base, countersignatory_revocation_base, countersignatory_htlc_base);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -165,7 +165,7 @@ public class TxCreationKeys extends CommonBase {
         */
        public static Result_TxCreationKeysErrorZ from_channel_static_keys(byte[] per_commitment_point, ChannelPublicKeys broadcaster_keys, ChannelPublicKeys countersignatory_keys) {
                long ret = bindings.TxCreationKeys_from_channel_static_keys(per_commitment_point, broadcaster_keys == null ? 0 : broadcaster_keys.ptr & ~1, countersignatory_keys == null ? 0 : countersignatory_keys.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(broadcaster_keys);
                ret_hu_conv.ptrs_to.add(countersignatory_keys);
index 62be067b87b1c4aa752c7706143f087d126f0423..1bfb88d122267ea76140833284ac8ed7898739b8 100644 (file)
@@ -87,7 +87,7 @@ public class Type extends CommonBase {
         */
        public Type clone() {
                long ret = bindings.Type_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Type ret_hu_conv = new Type(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
index d0d7662f31b330b42d8afa1362544ce074030102..4d0b7c75069510ea4a1d54d659720751849e65ae 100644 (file)
@@ -24,8 +24,8 @@ public class UnsignedChannelAnnouncement extends CommonBase {
         */
        public ChannelFeatures get_features() {
                long ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -132,8 +132,8 @@ public class UnsignedChannelAnnouncement extends CommonBase {
         */
        public UnsignedChannelAnnouncement clone() {
                long ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedChannelAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -151,7 +151,7 @@ public class UnsignedChannelAnnouncement extends CommonBase {
         */
        public static Result_UnsignedChannelAnnouncementDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UnsignedChannelAnnouncement_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 263dd91404addfc460822b48b9c29b5b450b1844..91a5557d2843e32f96435c55b1a7794ad7879fed 100644 (file)
@@ -158,8 +158,8 @@ public class UnsignedChannelUpdate extends CommonBase {
         */
        public UnsignedChannelUpdate clone() {
                long ret = bindings.UnsignedChannelUpdate_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedChannelUpdate(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -177,7 +177,7 @@ public class UnsignedChannelUpdate extends CommonBase {
         */
        public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UnsignedChannelUpdate_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 313a410f8553f786b93d7faa63480c5f78dada60..57021d8fda74b8454976c1f3db17d28badb76c3d 100644 (file)
@@ -24,8 +24,8 @@ public class UnsignedNodeAnnouncement extends CommonBase {
         */
        public NodeFeatures get_features() {
                long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               NodeFeatures ret_hu_conv = new NodeFeatures(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeFeatures(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -113,8 +113,8 @@ public class UnsignedNodeAnnouncement extends CommonBase {
         */
        public UnsignedNodeAnnouncement clone() {
                long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UnsignedNodeAnnouncement ret_hu_conv = new UnsignedNodeAnnouncement(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -132,7 +132,7 @@ public class UnsignedNodeAnnouncement extends CommonBase {
         */
        public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UnsignedNodeAnnouncement_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c0c56a16d2eff3b49757629118606e717c2209db..589d5548b0d827ac937b6e1936c928920e74364d 100644 (file)
@@ -99,8 +99,8 @@ public class UpdateAddHTLC extends CommonBase {
         */
        public UpdateAddHTLC clone() {
                long ret = bindings.UpdateAddHTLC_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateAddHTLC ret_hu_conv = new UpdateAddHTLC(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateAddHTLC(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -118,7 +118,7 @@ public class UpdateAddHTLC extends CommonBase {
         */
        public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UpdateAddHTLC_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 7f2c350ccde6ddc27c0fdfb22655e44664ac63c1..3bcb2b0a584e1d45cd0d71e538dde253055b2647 100644 (file)
@@ -54,8 +54,8 @@ public class UpdateFailHTLC extends CommonBase {
         */
        public UpdateFailHTLC clone() {
                long ret = bindings.UpdateFailHTLC_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFailHTLC ret_hu_conv = new UpdateFailHTLC(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFailHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFailHTLC(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -73,7 +73,7 @@ public class UpdateFailHTLC extends CommonBase {
         */
        public static Result_UpdateFailHTLCDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UpdateFailHTLC_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 40f02c294dbfcf67ea1bbc475fd4dfa87fd8dda5..68e48eff9e82f43d8669dc7a733e6a293c1eb002 100644 (file)
@@ -69,8 +69,8 @@ public class UpdateFailMalformedHTLC extends CommonBase {
         */
        public UpdateFailMalformedHTLC clone() {
                long ret = bindings.UpdateFailMalformedHTLC_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFailMalformedHTLC ret_hu_conv = new UpdateFailMalformedHTLC(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFailMalformedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFailMalformedHTLC(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -88,7 +88,7 @@ public class UpdateFailMalformedHTLC extends CommonBase {
         */
        public static Result_UpdateFailMalformedHTLCDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UpdateFailMalformedHTLC_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFailMalformedHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailMalformedHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index c477be1507ae2e7c3b8dd642311dce75fdaea712..d5f5a6e64bf175a16f3e316b94fb23724dab6426 100644 (file)
@@ -54,8 +54,8 @@ public class UpdateFee extends CommonBase {
         */
        public static UpdateFee of(byte[] channel_id_arg, int feerate_per_kw_arg) {
                long ret = bindings.UpdateFee_new(channel_id_arg, feerate_per_kw_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFee ret_hu_conv = new UpdateFee(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -65,8 +65,8 @@ public class UpdateFee extends CommonBase {
         */
        public UpdateFee clone() {
                long ret = bindings.UpdateFee_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFee ret_hu_conv = new UpdateFee(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -84,7 +84,7 @@ public class UpdateFee extends CommonBase {
         */
        public static Result_UpdateFeeDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UpdateFee_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 606408db70b964f44703258104eafa456748ffaf..0b34f89869b7c4680a420611ca0670d35bc62653 100644 (file)
@@ -69,8 +69,8 @@ public class UpdateFulfillHTLC extends CommonBase {
         */
        public static UpdateFulfillHTLC of(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
                long ret = bindings.UpdateFulfillHTLC_new(channel_id_arg, htlc_id_arg, payment_preimage_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFulfillHTLC ret_hu_conv = new UpdateFulfillHTLC(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFulfillHTLC(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -80,8 +80,8 @@ public class UpdateFulfillHTLC extends CommonBase {
         */
        public UpdateFulfillHTLC clone() {
                long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UpdateFulfillHTLC ret_hu_conv = new UpdateFulfillHTLC(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFulfillHTLC(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -99,7 +99,7 @@ public class UpdateFulfillHTLC extends CommonBase {
         */
        public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
                long ret = bindings.UpdateFulfillHTLC_read(ser);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
index 97efe64943b8ac1c736b46c1d86e24c989f27072..2037a9f1e7a94980f88c5f99aeda5902e3d87230 100644 (file)
@@ -27,8 +27,8 @@ public class UserConfig extends CommonBase {
         */
        public ChannelHandshakeConfig get_own_channel_config() {
                long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -45,8 +45,8 @@ public class UserConfig extends CommonBase {
         */
        public ChannelHandshakeLimits get_peer_channel_config_limits() {
                long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -63,8 +63,8 @@ public class UserConfig extends CommonBase {
         */
        public ChannelConfig get_channel_options() {
                long ret = bindings.UserConfig_get_channel_options(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -126,8 +126,8 @@ public class UserConfig extends CommonBase {
         */
        public static UserConfig of(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg, boolean accept_forwards_to_priv_channels_arg) {
                long ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1, accept_forwards_to_priv_channels_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UserConfig ret_hu_conv = new UserConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -137,8 +137,8 @@ public class UserConfig extends CommonBase {
         */
        public UserConfig clone() {
                long ret = bindings.UserConfig_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               UserConfig ret_hu_conv = new UserConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -148,8 +148,8 @@ public class UserConfig extends CommonBase {
         */
        public static UserConfig with_default() {
                long ret = bindings.UserConfig_default();
-               if (ret >= 0 && ret < 1024) { return null; }
-               UserConfig ret_hu_conv = new UserConfig(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
index ec9fda76ca07c38a4d50c5d38244cba7c0e0a0db..dac1f32ce06ef0e9da6ea26cc7ecf08f8113daf9 100644 (file)
@@ -12,7 +12,7 @@ public class UtilMethods {
         */
        public static Result_StringErrorZ sign(byte[] msg, byte[] sk) {
                long ret = bindings.sign(msg, sk);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_StringErrorZ ret_hu_conv = Result_StringErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -22,7 +22,7 @@ public class UtilMethods {
         */
        public static Result_PublicKeyErrorZ recover_pk(byte[] msg, java.lang.String sig) {
                long ret = bindings.recover_pk(msg, sig);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -41,7 +41,7 @@ public class UtilMethods {
         */
        public static Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(byte[] ser, KeysInterface arg) {
                long ret = bindings.C2Tuple_BlockHashChannelMonitorZ_read(ser, arg == null ? 0 : arg.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(arg);
                return ret_hu_conv;
@@ -52,7 +52,7 @@ public class UtilMethods {
         */
        public static Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(byte[] ser, KeysInterface arg_keys_manager, FeeEstimator arg_fee_estimator, Watch arg_chain_monitor, BroadcasterInterface arg_tx_broadcaster, Logger arg_logger, UserConfig arg_default_config, ChannelMonitor[] arg_channel_monitors) {
                long ret = bindings.C2Tuple_BlockHashChannelManagerZ_read(ser, bindings.ChannelManagerReadArgs_new(arg_keys_manager == null ? 0 : arg_keys_manager.ptr, arg_fee_estimator == null ? 0 : arg_fee_estimator.ptr, arg_chain_monitor == null ? 0 : arg_chain_monitor.ptr, arg_tx_broadcaster == null ? 0 : arg_tx_broadcaster.ptr, arg_logger == null ? 0 : arg_logger.ptr, arg_default_config == null ? 0 : arg_default_config.ptr & ~1, arg_channel_monitors != null ? Arrays.stream(arg_channel_monitors).mapToLong(arg_channel_monitors_conv_16 -> arg_channel_monitors_conv_16 == null ? 0 : arg_channel_monitors_conv_16.ptr & ~1).toArray() : null));
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ ret_hu_conv = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(arg_keys_manager);
                ret_hu_conv.ptrs_to.add(arg_fee_estimator);
@@ -89,7 +89,7 @@ public class UtilMethods {
         */
        public static Result_SecretKeyErrorZ derive_private_key(byte[] per_commitment_point, byte[] base_secret) {
                long ret = bindings.derive_private_key(per_commitment_point, base_secret);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -104,7 +104,7 @@ public class UtilMethods {
         */
        public static Result_PublicKeyErrorZ derive_public_key(byte[] per_commitment_point, byte[] base_point) {
                long ret = bindings.derive_public_key(per_commitment_point, base_point);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -122,7 +122,7 @@ public class UtilMethods {
         */
        public static Result_SecretKeyErrorZ derive_private_revocation_key(byte[] per_commitment_secret, byte[] countersignatory_revocation_base_secret) {
                long ret = bindings.derive_private_revocation_key(per_commitment_secret, countersignatory_revocation_base_secret);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_SecretKeyErrorZ ret_hu_conv = Result_SecretKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -142,7 +142,7 @@ public class UtilMethods {
         */
        public static Result_PublicKeyErrorZ derive_public_revocation_key(byte[] per_commitment_point, byte[] countersignatory_revocation_base_point) {
                long ret = bindings.derive_public_revocation_key(per_commitment_point, countersignatory_revocation_base_point);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -206,51 +206,42 @@ public class UtilMethods {
        }
 
        /**
-        * Gets a keysend route from us (payer) to the given target node (payee). This is needed because
-        * keysend payments do not have an invoice from which to pull the payee's supported features, which
-        * makes it tricky to otherwise supply the `payee_features` parameter of `get_route`.
+        * Finds a route from us (payer) to the given target node (payee).
         * 
-        * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
-        */
-       public static Result_RouteLightningErrorZ get_keysend_route(byte[] our_node_pubkey, NetworkGraph network, byte[] payee, @Nullable ChannelDetails[] first_hops, RouteHint[] last_hops, long final_value_msat, int final_cltv, Logger logger, Score scorer) {
-               long ret = bindings.get_keysend_route(our_node_pubkey, network == null ? 0 : network.ptr & ~1, payee, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, last_hops != null ? Arrays.stream(last_hops).mapToLong(last_hops_conv_11 -> last_hops_conv_11 == null ? 0 : last_hops_conv_11.ptr & ~1).toArray() : null, final_value_msat, final_cltv, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(network);
-               for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
-               ret_hu_conv.ptrs_to.add(logger);
-               ret_hu_conv.ptrs_to.add(scorer);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Gets a route from us (payer) to the given target node (payee).
-        * 
-        * If the payee provided features in their invoice, they should be provided via payee_features.
+        * If the payee provided features in their invoice, they should be provided via `params.payee`.
         * Without this, MPP will only be used if the payee's features are available in the network graph.
         * 
-        * Private routing paths between a public node and the target may be included in `last_hops`.
-        * Currently, only the last hop in each path is considered.
+        * Private routing paths between a public node and the target may be included in `params.payee`.
+        * 
+        * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
+        * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of our local
+        * channels from [`NetworkGraph`] will be ignored, and only those in `first_hops` will be used.
+        * 
+        * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
+        * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
+        * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
+        * 
+        * # Note
+        * 
+        * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
+        * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
+        * function.
         * 
-        * If some channels aren't announced, it may be useful to fill in a first_hops with the
-        * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our
-        * view of our local channels (from net_graph_msg_handler) will be ignored, and only those
-        * in first_hops will be used.
+        * # Panics
         * 
-        * Panics if first_hops contains channels without short_channel_ids
-        * (ChannelManager::list_usable_channels will never include such channels).
+        * Panics if first_hops contains channels without short_channel_ids;
+        * [`ChannelManager::list_usable_channels`] will never include such channels.
         * 
-        * The fees on channels from us to next-hops are ignored (as they are assumed to all be
-        * equal), however the enabled/disabled bit on such channels as well as the
-        * htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node.
+        * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
+        * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
         * 
-        * Note that payee_features (or a relevant inner pointer) may be NULL or all-0s to represent None
         * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public static Result_RouteLightningErrorZ get_route(byte[] our_node_pubkey, NetworkGraph network, byte[] payee, @Nullable InvoiceFeatures payee_features, @Nullable ChannelDetails[] first_hops, RouteHint[] last_hops, long final_value_msat, int final_cltv, Logger logger, Score scorer) {
-               long ret = bindings.get_route(our_node_pubkey, network == null ? 0 : network.ptr & ~1, payee, payee_features == null ? 0 : payee_features.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, last_hops != null ? Arrays.stream(last_hops).mapToLong(last_hops_conv_11 -> last_hops_conv_11 == null ? 0 : last_hops_conv_11.ptr & ~1).toArray() : null, final_value_msat, final_cltv, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
+       public static Result_RouteLightningErrorZ find_route(byte[] our_node_pubkey, RouteParameters params, NetworkGraph network, @Nullable ChannelDetails[] first_hops, Logger logger, Score scorer) {
+               long ret = bindings.find_route(our_node_pubkey, params == null ? 0 : params.ptr & ~1, network == null ? 0 : network.ptr & ~1, first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(params);
                ret_hu_conv.ptrs_to.add(network);
                for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
                ret_hu_conv.ptrs_to.add(logger);
@@ -264,7 +255,7 @@ public class UtilMethods {
         */
        public static Result_NoneErrorZ FilesystemPersister_persist_manager(java.lang.String data_dir, ChannelManager manager) {
                long ret = bindings.FilesystemPersister_persist_manager(data_dir, manager == null ? 0 : manager.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(manager);
                return ret_hu_conv;
@@ -279,7 +270,7 @@ public class UtilMethods {
         */
        public static Result_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(ChannelManager channelmanager, KeysInterface keys_manager, org.ldk.enums.Currency network, Option_u64Z amt_msat, java.lang.String description) {
                long ret = bindings.create_invoice_from_channelmanager(channelmanager == null ? 0 : channelmanager.ptr & ~1, keys_manager == null ? 0 : keys_manager.ptr, network, amt_msat.ptr, description);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_InvoiceSignOrCreationErrorZ ret_hu_conv = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(channelmanager);
                ret_hu_conv.ptrs_to.add(keys_manager);
index 11482c5d587cda776bfe56970da1002044009aa7..be66801bf7bae8108d3c6bbd96a5982538f3b7ab 100644 (file)
@@ -69,6 +69,13 @@ public class Watch extends CommonBase {
                /**
                 * Returns any monitor events since the last call. Subsequent calls must only return new
                 * events.
+                * 
+                * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no
+                * further events may be returned here until the [`ChannelMonitor`] has been fully persisted
+                * to disk.
+                * 
+                * For details on asynchronous [`ChannelMonitor`] updating and returning
+                * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`].
                 */
                MonitorEvent[] release_pending_monitor_events();
        }
@@ -77,18 +84,18 @@ public class Watch extends CommonBase {
                final LDKWatchHolder impl_holder = new LDKWatchHolder();
                impl_holder.held = new Watch(new bindings.LDKWatch() {
                        @Override public long watch_channel(long funding_txo, long monitor) {
-                               OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo);
+                               OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new OutPoint(null, funding_txo); }
                                funding_txo_hu_conv.ptrs_to.add(this);
-                               ChannelMonitor monitor_hu_conv = new ChannelMonitor(null, monitor);
+                               ChannelMonitor monitor_hu_conv = null; if (monitor < 0 || monitor > 4096) { monitor_hu_conv = new ChannelMonitor(null, monitor); }
                                monitor_hu_conv.ptrs_to.add(this);
                                Result_NoneChannelMonitorUpdateErrZ ret = arg.watch_channel(funding_txo_hu_conv, monitor_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
                                return result;
                        }
                        @Override public long update_channel(long funding_txo, long update) {
-                               OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo);
+                               OutPoint funding_txo_hu_conv = null; if (funding_txo < 0 || funding_txo > 4096) { funding_txo_hu_conv = new OutPoint(null, funding_txo); }
                                funding_txo_hu_conv.ptrs_to.add(this);
-                               ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update);
+                               ChannelMonitorUpdate update_hu_conv = null; if (update < 0 || update > 4096) { update_hu_conv = new ChannelMonitorUpdate(null, update); }
                                update_hu_conv.ptrs_to.add(this);
                                Result_NoneChannelMonitorUpdateErrZ ret = arg.update_channel(funding_txo_hu_conv, update_hu_conv);
                                long result = ret != null ? ret.ptr : 0;
@@ -118,7 +125,7 @@ public class Watch extends CommonBase {
         */
        public Result_NoneChannelMonitorUpdateErrZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor) {
                long ret = bindings.Watch_watch_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, monitor == null ? 0 : monitor.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -133,7 +140,7 @@ public class Watch extends CommonBase {
         */
        public Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo, ChannelMonitorUpdate update) {
                long ret = bindings.Watch_update_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, update == null ? 0 : update.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -141,6 +148,13 @@ public class Watch extends CommonBase {
        /**
         * Returns any monitor events since the last call. Subsequent calls must only return new
         * events.
+        * 
+        * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no
+        * further events may be returned here until the [`ChannelMonitor`] has been fully persisted
+        * to disk.
+        * 
+        * For details on asynchronous [`ChannelMonitor`] updating and returning
+        * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`].
         */
        public MonitorEvent[] release_pending_monitor_events() {
                long[] ret = bindings.Watch_release_pending_monitor_events(this.ptr);
index bfb953287107d8143a0b44d80c77caecdd77f8ac..2014286be97b0751c91150819184870f7be2d40b 100644 (file)
@@ -54,8 +54,8 @@ public class WatchedOutput extends CommonBase {
         */
        public OutPoint get_outpoint() {
                long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               OutPoint ret_hu_conv = new OutPoint(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -87,8 +87,8 @@ public class WatchedOutput extends CommonBase {
         */
        public static WatchedOutput of(byte[] block_hash_arg, OutPoint outpoint_arg, byte[] script_pubkey_arg) {
                long ret = bindings.WatchedOutput_new(block_hash_arg, outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, script_pubkey_arg);
-               if (ret >= 0 && ret < 1024) { return null; }
-               WatchedOutput ret_hu_conv = new WatchedOutput(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -98,8 +98,8 @@ public class WatchedOutput extends CommonBase {
         */
        public WatchedOutput clone() {
                long ret = bindings.WatchedOutput_clone(this.ptr);
-               if (ret >= 0 && ret < 1024) { return null; }
-               WatchedOutput ret_hu_conv = new WatchedOutput(null, ret);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
index 83b7eee59ea06a5b215612861161fb44eaace0a0..32c632986f58672536c0ba3b5c0677969908a468 100644 (file)
@@ -11,7 +11,8 @@
 
 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
+#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
+#define CHECK_ACCESS(p)
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
 
@@ -796,18 +797,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysD
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -817,18 +820,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKe
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelPublicKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -838,9 +843,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysE
        LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -884,18 +890,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCom
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCOutputInCommitment res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -905,18 +913,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyCha
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -926,18 +936,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransact
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -947,18 +959,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmen
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHolderCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -968,18 +982,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitment
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -989,9 +1005,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingT
        LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedClosingTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       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) {
@@ -1006,18 +1023,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTrans
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1027,9 +1046,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitme
        LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1044,13 +1064,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1Sign
        LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_SignatureZ res_var = (*val->contents.result);
-       jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray res_arr = NULL;
+       res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < res_var.datalen; i++) {
                int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
                (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
                (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
        }
+       
        return res_arr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1065,18 +1087,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptD
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1086,18 +1110,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptI
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKInvalidShutdownScript err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1121,18 +1147,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeE
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRouteHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -1176,20 +1204,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErro
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+       ret->datalen = (*env)->GetArrayLength(env, elems);
+       if (ret->datalen == 0) {
+               ret->data = NULL;
+       } else {
+               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ 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];
+                       LDKRouteHint arr_elem_conv;
+                       arr_elem_conv.inner = (void*)(arr_elem & (~1));
+                       arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       ret->data[i] = arr_elem_conv;
+               }
+               (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+       }
+       return (uint64_t)ret;
+}
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = RouteHint_clone(&orig->data[i]);
+       }
+       return ret;
+}
 static jclass LDKCOption_u64Z_Some_class = NULL;
 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
 static jclass LDKCOption_u64Z_None_class = NULL;
@@ -1218,57 +1298,126 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from
                default: abort();
        }
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
-       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKPayee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
        ret->datalen = (*env)->GetArrayLength(env, elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
+               ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ 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];
-                       LDKChannelDetails arr_elem_conv;
+                       LDKRouteHintHop arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
+                       arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
                (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
-       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
+       LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+               ret.data[i] = RouteHintHop_clone(&orig->data[i]);
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
-       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHintHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
        ret->datalen = (*env)->GetArrayLength(env, elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
+               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ 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];
-                       LDKRouteHint arr_elem_conv;
+                       LDKChannelDetails arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
                (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
-       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = RouteHint_clone(&orig->data[i]);
+               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
        }
        return ret;
 }
@@ -1279,18 +1428,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningE
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1308,17 +1459,6 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessError
        jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
        return err_conv;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
-       LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
-       ret->a = a;
-       LDKTransaction b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       b_ref.data_is_owned = false;
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -1350,7 +1490,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTran
                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_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1390,6 +1532,10 @@ static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
+static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
+static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
+static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
+static jmethodID LDKMonitorEvent_UpdateFailed_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;"));
@@ -1401,24 +1547,52 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNI
        CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
        LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
        CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
+       LDKMonitorEvent_UpdateCompleted_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted;"));
+       CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
+       LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
+       CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
+       LDKMonitorEvent_UpdateFailed_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed;"));
+       CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
+       LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
+       CHECK(LDKMonitorEvent_UpdateFailed_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);
        switch(obj->tag) {
                case LDKMonitorEvent_HTLCEvent: {
                        LDKHTLCUpdate htlc_event_var = obj->htlc_event;
+                       uint64_t htlc_event_ref = 0;
                        CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
+                       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_CommitmentTxConfirmed: {
                        LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
+                       uint64_t commitment_tx_confirmed_ref = 0;
                        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;
+                       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);
                }
+               case LDKMonitorEvent_UpdateCompleted: {
+                       LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
+                       uint64_t funding_txo_ref = 0;
+                       CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
+               }
+               case LDKMonitorEvent_UpdateFailed: {
+                       LDKOutPoint update_failed_var = obj->update_failed;
+                       uint64_t update_failed_ref = 0;
+                       CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
+               }
                default: abort();
        }
 }
@@ -1432,7 +1606,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new
                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];
-                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
                        arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1506,9 +1682,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from
        switch(obj->tag) {
                case LDKNetworkUpdate_ChannelUpdateMessage: {
                        LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
                }
                case LDKNetworkUpdate_ChannelClosed: {
@@ -1579,24 +1756,27 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescripto
        switch(obj->tag) {
                case LDKSpendableOutputDescriptor_StaticOutput: {
                        LDKOutPoint outpoint_var = obj->static_output.outpoint;
+                       uint64_t outpoint_ref = 0;
                        CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
+                       outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
                        uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
                }
                case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
                        LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
+                       uint64_t delayed_payment_output_ref = 0;
                        CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
+                       delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
                }
                case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
                        LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
+                       uint64_t static_payment_output_ref = 0;
                        CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
+                       static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
                }
                default: abort();
@@ -1612,7 +1792,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDes
                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];
-                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
                        arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1662,9 +1844,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1
        switch(obj->tag) {
                case LDKErrorAction_DisconnectPeer: {
                        LDKErrorMessage msg_var = obj->disconnect_peer.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;
+                       uint64_t msg_ref = 0;
+                       if ((uint64_t)msg_var.inner > 4096) {
+                               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.
+                               msg_ref = (uint64_t)msg_var.inner & ~1;
+                       }
                        return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
                }
                case LDKErrorAction_IgnoreError: {
@@ -1676,9 +1861,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1
                }
                case LDKErrorAction_SendErrorMessage: {
                        LDKErrorMessage msg_var = obj->send_error_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
                }
                default: abort();
@@ -1826,133 +2012,149 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
                        LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendOpenChannel: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
                        LDKOpenChannel msg_var = obj->send_open_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingCreated: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
                        LDKFundingCreated msg_var = obj->send_funding_created.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingSigned: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
                        LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingLocked: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
                        LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendAnnouncementSignatures: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
                        LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_UpdateHTLCs: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
                        LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+                       uint64_t updates_ref = 0;
                        CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
+                       updates_ref = (uint64_t)updates_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
                }
                case LDKMessageSendEvent_SendRevokeAndACK: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
                        LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendClosingSigned: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
                        LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendShutdown: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
                        LDKShutdown msg_var = obj->send_shutdown.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendChannelReestablish: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
                        LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
                        LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+                       uint64_t update_msg_ref = 0;
                        CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+                       update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
                }
                case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
                        LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
                }
                case LDKMessageSendEvent_BroadcastChannelUpdate: {
                        LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
                }
                case LDKMessageSendEvent_SendChannelUpdate: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
                        LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_HandleError: {
@@ -1965,27 +2167,30 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f
                        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);
                        LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendShortIdsQuery: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
                        LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendReplyChannelRange: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
                        LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
                }
                default: abort();
@@ -2001,7 +2206,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_
                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];
-                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
                        arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2023,18 +2230,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDec
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInitFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2044,18 +2253,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDec
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2065,18 +2276,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeatures
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2086,18 +2299,66 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeatures
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoiceFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScoringParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScorer res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2107,18 +2368,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentO
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2128,18 +2391,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOu
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2155,9 +2420,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutput
        LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -2173,28 +2439,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1er
        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;
-       CHECK((*env)->GetArrayLength(env, a) == 64);
-       (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
-       ret->a = a_ref;
-       LDKCVec_SignatureZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
-       else
-               b_constr.data = NULL;
-       for (size_t i = 0; i < b_constr.datalen; i++) {
-               int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
-               LDKSignature b_conv_8_ref;
-               CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
-               (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
-               b_constr.data[i] = b_conv_8_ref;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -2211,13 +2455,15 @@ static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(
 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
        LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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, 64);
                (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -2346,10 +2592,11 @@ LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* th
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
+       uint64_t holder_tx_ref = 0;
        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;
+       holder_tx_ref = (uint64_t)holder_tx_var.inner;
        if (holder_tx_var.is_owned) {
                holder_tx_ref |= 1;
        }
@@ -2360,7 +2607,9 @@ LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* th
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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);
@@ -2401,10 +2650,11 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
@@ -2415,7 +2665,9 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2440,7 +2692,9 @@ LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const vo
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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);
@@ -2457,10 +2711,11 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htl
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
@@ -2471,7 +2726,9 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2500,7 +2757,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const vo
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2523,10 +2782,11 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
        int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
@@ -2537,7 +2797,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2560,10 +2822,11 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
        int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
@@ -2574,7 +2837,9 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2591,10 +2856,11 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void*
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKClosingTransaction closing_tx_var = *closing_tx;
-       // Warning: we may need a move here but no clone is available for LDKClosingTransaction
+       uint64_t closing_tx_ref = 0;
+       closing_tx_var = ClosingTransaction_clone(closing_tx);
        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;
+       closing_tx_ref = (uint64_t)closing_tx_var.inner;
        if (closing_tx_var.is_owned) {
                closing_tx_ref |= 1;
        }
@@ -2605,7 +2871,9 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2622,10 +2890,11 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKUnsignedChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UnsignedChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -2636,7 +2905,9 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2653,10 +2924,11 @@ void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransaction
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+       uint64_t channel_parameters_ref = 0;
        channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
        CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+       channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
        if (channel_parameters_var.is_owned) {
                channel_parameters_ref |= 1;
        }
@@ -2737,21 +3009,27 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *en
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
        return ret_arr;
 }
 
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction holder_tx_conv;
        holder_tx_conv.inner = (void*)(holder_tx & (~1));
        holder_tx_conv.is_owned = false;
@@ -2761,14 +3039,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
        return ret_arr;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -2778,7 +3060,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        unsigned char secret_arr[32];
        CHECK((*env)->GetArrayLength(env, secret) == 32);
        (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
@@ -2789,7 +3073,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counter
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -2799,7 +3085,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1com
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2815,7 +3103,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1re
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2834,7 +3124,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1re
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction htlc_tx_ref;
        htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
        htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2852,7 +3144,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKClosingTransaction closing_tx_conv;
        closing_tx_conv.inner = (void*)(closing_tx & (~1));
        closing_tx_conv.is_owned = false;
@@ -2862,7 +3156,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1tr
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -2872,7 +3168,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1an
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelTransactionParameters channel_parameters_conv;
        channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
        channel_parameters_conv.is_owned = false;
@@ -2885,11 +3183,14 @@ LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
        return this_arg->pubkeys;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2987,7 +3288,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIE
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
        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);
@@ -3001,7 +3304,7 @@ 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* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *res_ret = Sign_clone(&(*val->contents.result));
        return (uint64_t)res_ret;
 }
@@ -3009,9 +3312,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeError
        LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3043,7 +3347,8 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec
        LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
-       jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray res_arr = NULL;
+       res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < res_var.datalen; i++) {
                LDKCVec_u8Z res_conv_8_var = res_var.data[i];
@@ -3051,6 +3356,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec
                (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
                (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
        }
+       
        return res_arr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3065,18 +3371,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerD
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInMemorySigner res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -3089,7 +3397,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv
                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];
-                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
                        arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3120,19 +3430,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKChannelMonitor b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelMonitor_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3149,9 +3446,10 @@ static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LD
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
        LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3168,7 +3466,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHash
                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_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3190,7 +3490,8 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tu
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
-       int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
+       int64_tArray res_arr = NULL;
+       res_arr = (*env)->NewLongArray(env, res_var.datalen);
        int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
        for (size_t j = 0; j < res_var.datalen; j++) {
                LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
@@ -3207,27 +3508,6 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1B
        jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
        return err_conv;
 }
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKPaymentId 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 int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(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;
-}
 static jclass LDKCOption_u16Z_Some_class = NULL;
 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
 static jclass LDKCOption_u16Z_None_class = NULL;
@@ -3328,9 +3608,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr
                }
                case LDKAPIError_IncompatibleShutdownScript: {
                        LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+                       uint64_t script_ref = 0;
                        CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t script_ref = (uint64_t)script_var.inner & ~1;
+                       script_ref = (uint64_t)script_var.inner & ~1;
                        return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
                }
                default: abort();
@@ -3360,7 +3641,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIEr
                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];
-                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
                        arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3385,7 +3668,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNI
                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];
-                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
                        arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3443,7 +3728,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_ini
        LDKPaymentSendFailure_PartialFailure_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
        CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
-       LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
+       LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
        CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
 }
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
@@ -3455,7 +3740,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                }
                case LDKPaymentSendFailure_PathParameterError: {
                        LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
-                       int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
+                       int64_tArray path_parameter_error_arr = NULL;
+                       path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
                        int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
                        for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
                                LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
@@ -3468,7 +3754,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                }
                case LDKPaymentSendFailure_AllFailedRetrySafe: {
                        LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
-                       int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
+                       int64_tArray all_failed_retry_safe_arr = NULL;
+                       all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
                        int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
                        for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
                                uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
@@ -3478,17 +3765,27 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                        return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
                }
                case LDKPaymentSendFailure_PartialFailure: {
-                       LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
-                       int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
-                       int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
-                       for (size_t w = 0; w < partial_failure_var.datalen; w++) {
-                               LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
-                               *partial_failure_conv_22_conv = partial_failure_var.data[w];
-                               *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
-                               partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
+                       LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+                       int64_tArray results_arr = NULL;
+                       results_arr = (*env)->NewLongArray(env, results_var.datalen);
+                       int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
+                       for (size_t w = 0; w < results_var.datalen; w++) {
+                               LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+                               *results_conv_22_conv = results_var.data[w];
+                               *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+                               results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
                        }
-                       (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
-                       return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
+                       (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
+                       LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+                       uint64_t failed_paths_retry_ref = 0;
+                       if ((uint64_t)failed_paths_retry_var.inner > 4096) {
+                               CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
+                       }
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
+                       return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
                }
                default: abort();
        }
@@ -3496,14 +3793,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKPaymentId 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;
+       int8_tArray res_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
+       return res_arr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
@@ -3525,19 +3820,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSend
        uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3548,19 +3830,14 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPay
        return ret_arr;
 }
 
-static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
-       return PaymentId_clone(&tuple->b);
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+       return ThirtyTwoBytes_clone(&tuple->b);
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
-       LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_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;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
+       return ret_arr;
 }
 
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3646,7 +3923,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(J
                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];
-                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
                        arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3661,18 +3940,6 @@ static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddres
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
-       LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKThirtyTwoBytes b_ref;
-       CHECK((*env)->GetArrayLength(env, b) == 32);
-       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3771,16 +4038,18 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void*
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitor monitor_var = monitor;
+       uint64_t monitor_ref = 0;
        CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t monitor_ref = (uint64_t)monitor_var.inner;
+       monitor_ref = (uint64_t)monitor_var.inner;
        if (monitor_var.is_owned) {
                monitor_ref |= 1;
        }
@@ -3791,7 +4060,9 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -3808,16 +4079,18 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = update;
+       uint64_t update_ref = 0;
        CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
+       update_ref = (uint64_t)update_var.inner;
        if (update_var.is_owned) {
                update_ref |= 1;
        }
@@ -3828,7 +4101,9 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -3860,7 +4135,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void*
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t o = 0; o < ret_constr.datalen; o++) {
                int64_t ret_conv_14 = ret_vals[o];
-               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
+               void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
+               CHECK_ACCESS(ret_conv_14_ptr);
+               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
                ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
                ret_constr.data[o] = ret_conv_14_conv;
        }
@@ -3903,7 +4180,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env,
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -3918,7 +4197,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEn
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -3933,13 +4214,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIE
 }
 
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
@@ -4022,7 +4306,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1ne
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
-       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
        LDKTransaction tx_ref;
        tx_ref.datalen = (*env)->GetArrayLength(env, tx);
        tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
@@ -4150,7 +4436,9 @@ LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inb
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
        }
-       LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKSign ret_conv = *(LDKSign*)(ret_ptr);
        ret_conv = Sign_clone(&ret_conv);
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4200,7 +4488,9 @@ LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
        }
-       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4227,7 +4517,9 @@ LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const v
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
        }
-       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4279,14 +4571,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEn
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
        return ret_arr;
 }
 
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(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);
@@ -4295,11 +4591,14 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1des
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4307,21 +4606,27 @@ 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+       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) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
        return ret_arr;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKu8slice reader_ref;
        reader_ref.datalen = (*env)->GetArrayLength(env, reader);
        reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
@@ -4332,7 +4637,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z invoice_preimage_ref;
        invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
        invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
@@ -4414,7 +4721,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_arg, jclass confirmation_target) {
-       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
        LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
        int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
        return ret_val;
@@ -4491,19 +4800,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env,
        *res_ptr = LDKLogger_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKChannelManager b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       // Warning: we need a move here but no clone is available for LDKChannelManager
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -4520,9 +4816,10 @@ static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(L
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
        LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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 & ~1;
+       ret_ref = (uint64_t)ret_var.inner & ~1;
        return ret_ref;
 }
 
@@ -4532,8 +4829,7 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1Block
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       *res_conv = (*val->contents.result);
+       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
        // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
        return ((uint64_t)res_conv) | 1;
 }
@@ -4541,9 +4837,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockH
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4553,18 +4850,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDe
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelConfig res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4574,18 +4873,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeE
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOutPoint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKType_JCalls {
@@ -4715,13 +5016,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, j
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -4729,7 +5034,9 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *en
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -4757,7 +5064,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1fro
        LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_TypeZ_Some: {
-                       LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
+                       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);
                }
@@ -4780,9 +5087,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZD
        LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+static jclass LDKPaymentError_Invoice_class = NULL;
+static jmethodID LDKPaymentError_Invoice_meth = NULL;
+static jclass LDKPaymentError_Routing_class = NULL;
+static jmethodID LDKPaymentError_Routing_meth = NULL;
+static jclass LDKPaymentError_Sending_class = NULL;
+static jmethodID LDKPaymentError_Sending_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
+       LDKPaymentError_Invoice_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Invoice;"));
+       CHECK(LDKPaymentError_Invoice_class != NULL);
+       LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
+       CHECK(LDKPaymentError_Invoice_meth != NULL);
+       LDKPaymentError_Routing_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Routing;"));
+       CHECK(LDKPaymentError_Routing_class != NULL);
+       LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
+       CHECK(LDKPaymentError_Routing_meth != NULL);
+       LDKPaymentError_Sending_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Sending;"));
+       CHECK(LDKPaymentError_Sending_class != NULL);
+       LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
+       CHECK(LDKPaymentError_Sending_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+       LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+       switch(obj->tag) {
+               case LDKPaymentError_Invoice: {
+                       LDKStr invoice_str = obj->invoice;
+                       jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
+                       return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
+               }
+               case LDKPaymentError_Routing: {
+                       LDKLightningError routing_var = obj->routing;
+                       uint64_t routing_ref = 0;
+                       CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       routing_ref = (uint64_t)routing_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
+               }
+               case LDKPaymentError_Sending: {
+                       uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
+                       return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
+               }
+               default: abort();
+       }
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       int8_tArray res_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
+       return res_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4806,9 +5176,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1g
        LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4823,9 +5194,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoic
        LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKSignedRawInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4833,33 +5205,16 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNo
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
-       LDKRawInvoice a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = RawInvoice_clone(&a_conv);
-       ret->a = a_conv;
-       LDKThirtyTwoBytes b_ref;
-       CHECK((*env)->GetArrayLength(env, b) == 32);
-       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
-       ret->b = b_ref;
-       LDKInvoiceSignature c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = InvoiceSignature_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
        return RawInvoice_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4882,9 +5237,10 @@ static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignature
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4898,9 +5254,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErro
        LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPayeePubKey res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4943,9 +5300,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimesta
        LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPositiveTimestamp res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4975,9 +5333,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemantic
        LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4993,9 +5352,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCrea
        LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDescription res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5011,9 +5371,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreat
        LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKExpiryTime res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5029,9 +5390,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCre
        LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPrivateRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5063,18 +5425,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorU
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelMonitorUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5084,18 +5448,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecod
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5110,34 +5476,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpda
        LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKMonitorUpdateError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
-       LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
-       LDKOutPoint a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = OutPoint_clone(&a_conv);
-       ret->a = a_conv;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
        return OutPoint_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
        LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5156,16 +5510,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScript
        return ret_arr;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
-       LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
-       ret->a = a;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5197,7 +5541,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32Script
                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_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5212,29 +5558,6 @@ static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const L
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32ScriptZZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
-       else
-               b_constr.data = NULL;
-       int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
-       for (size_t v = 0; v < b_constr.datalen; v++) {
-               int64_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
-               b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
-               b_constr.data[v] = b_conv_21_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -5251,7 +5574,8 @@ static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32Scr
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t v = 0; v < ret_var.datalen; v++) {
                LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
@@ -5273,7 +5597,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_
                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_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5436,12 +5762,12 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en
        LDKEvent_PaymentSent_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
        CHECK(LDKEvent_PaymentSent_class != NULL);
-       LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B)V");
+       LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
        CHECK(LDKEvent_PaymentSent_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, "<init>", "([BZJZ[JJ)V");
+       LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
        CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
        LDKEvent_PendingHTLCsForwardable_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
@@ -5487,36 +5813,51 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN
                        return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
                }
                case LDKEvent_PaymentSent: {
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
                        int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
                        (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
                        int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
                        (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
-                       return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr, payment_hash_arr);
+                       uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+                       return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
                }
                case LDKEvent_PaymentPathFailed: {
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
                        int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
                        (*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_tArray path_arr = NULL;
+                       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];
+                               uint64_t path_conv_10_ref = 0;
                                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_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);
                        uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
-                       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, short_channel_id_ref);
+                       LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+                       uint64_t retry_ref = 0;
+                       if ((uint64_t)retry_var.inner > 4096) {
+                               CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               retry_ref = (uint64_t)retry_var.inner & ~1;
+                       }
+                       return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
                }
                case LDKEvent_PendingHTLCsForwardable: {
                        return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
                }
                case LDKEvent_SpendableOutputs: {
                        LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
-                       int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
+                       int64_tArray outputs_arr = NULL;
+                       outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
                        int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
                        for (size_t b = 0; b < outputs_var.datalen; b++) {
                                uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
@@ -5556,7 +5897,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv
                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];
-                       LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
                        arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5571,14 +5914,6 @@ static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
-       LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
-       ret->a = a;
-       LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
-       b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5608,7 +5943,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZ
                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_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5623,29 +5960,6 @@ static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDK
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32TxOutZZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
-       else
-               b_constr.data = NULL;
-       int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
-       for (size_t u = 0; u < b_constr.datalen; u++) {
-               int64_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
-               b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
-               b_constr.data[u] = b_conv_20_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -5662,7 +5976,8 @@ static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOu
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t u = 0; u < ret_var.datalen; u++) {
                LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
@@ -5684,7 +5999,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_
                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_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5757,7 +6074,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIE
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
                        arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5787,9 +6106,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockH
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -5804,22 +6124,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningEr
        LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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;
-}
 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5835,7 +6145,7 @@ static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTy
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
-       LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
+       LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
        *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
        return (uint64_t)ret_ret;
 }
@@ -5850,7 +6160,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKey
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5877,39 +6189,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningEr
        LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
-       LDKChannelAnnouncement a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = ChannelAnnouncement_clone(&a_conv);
-       ret->a = a_conv;
-       LDKChannelUpdate b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelUpdate_clone(&b_conv);
-       ret->b = b_conv;
-       LDKChannelUpdate c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = ChannelUpdate_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
        return ChannelAnnouncement_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5922,9 +6217,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5937,9 +6233,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5956,7 +6253,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAn
                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];
-                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
                        arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -6013,9 +6312,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHa
        LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6030,9 +6330,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleE
        LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6047,9 +6348,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleE
        LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6059,18 +6361,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErr
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeId res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKAccess_JCalls {
@@ -6114,7 +6418,9 @@ LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, cons
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
        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);
@@ -6148,7 +6454,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env,
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
        unsigned char genesis_hash_arr[32];
        CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
        (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
@@ -6178,7 +6486,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1f
        LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_AccessZ_Some: {
-                       LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
+                       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) {
@@ -6200,18 +6508,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChan
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDirectionalChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6221,18 +6531,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDeco
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6242,18 +6554,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDeco
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoutingFees res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6263,18 +6577,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncemen
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncementInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -6304,18 +6620,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeE
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6325,18 +6643,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDec
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNetworkGraph res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
@@ -6360,7 +6680,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddres
        switch(obj->tag) {
                case LDKCOption_CVec_NetAddressZZ_Some: {
                        LDKCVec_NetAddressZ some_var = obj->some;
-                       int64_tArray some_arr = (*env)->NewLongArray(env, some_var.datalen);
+                       int64_tArray some_arr = NULL;
+                       some_arr = (*env)->NewLongArray(env, some_var.datalen);
                        int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
                        for (size_t m = 0; m < some_var.datalen; m++) {
                                uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
@@ -6375,40 +6696,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddres
                default: abort();
        }
 }
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(val->result_ok);
-       uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
-       return res_ref;
-}
-JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(!val->result_ok);
-       return *val->contents.err;
-}
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *res_conv = (*val->contents.result);
-       *res_conv = CResult_NetAddressu8Z_clone(res_conv);
-       return (uint64_t)res_conv;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(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_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
 }
@@ -6422,9 +6709,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecod
        LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -6542,18 +6830,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDe
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAcceptChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6563,18 +6853,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSig
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAnnouncementSignatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6584,18 +6876,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestabl
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelReestablish res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6605,18 +6899,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDe
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6626,18 +6922,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFe
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSignedFeeRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6647,18 +6945,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSigne
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6668,18 +6968,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedD
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingCreated res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6689,18 +6991,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDe
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6710,18 +7014,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDe
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingLocked res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6731,18 +7037,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeError
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInit res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6752,18 +7060,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDeco
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOpenChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6773,18 +7083,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDec
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRevokeAndACK res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6794,18 +7106,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeE
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdown res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6815,18 +7129,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCD
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6836,18 +7152,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalfo
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6857,18 +7175,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecode
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6878,18 +7198,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHT
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFulfillHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6899,18 +7221,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDe
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateAddHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6920,18 +7244,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeError
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPing res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6941,18 +7267,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeError
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPong res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6962,18 +7290,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannel
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6983,18 +7313,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnounce
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7004,18 +7336,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannel
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7025,18 +7359,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDe
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7046,18 +7382,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDec
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKErrorMessage res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7067,18 +7405,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnn
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7088,18 +7428,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncemen
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7109,18 +7451,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChann
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryShortChannelIds res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7130,18 +7474,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChann
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7151,18 +7497,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRan
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7172,18 +7520,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRan
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7193,18 +7543,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestamp
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKGossipTimestampFilter res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 static jclass LDKSignOrCreationError_SignError_class = NULL;
@@ -7243,9 +7595,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCr
        LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7313,9 +7666,10 @@ LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKWatchedOutput output_var = output;
+       uint64_t output_ref = 0;
        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;
+       output_ref = (uint64_t)output_var.inner;
        if (output_var.is_owned) {
                output_ref |= 1;
        }
@@ -7326,7 +7680,9 @@ LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
        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);
@@ -7363,7 +7719,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env,
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
@@ -7376,7 +7734,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *e
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        LDKWatchedOutput output_conv;
        output_conv.inner = (void*)(output & (~1));
        output_conv.is_owned = (output & 1) || (output == 0);
@@ -7407,7 +7767,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1f
        LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_FilterZ_Some: {
-                       LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
+                       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) {
@@ -7429,9 +7789,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMo
        LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKLockedChannelMonitor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7514,7 +7875,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP
        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);
+               void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
+               CHECK_ACCESS(ret_conv_18_ptr);
+               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
                ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
                ret_constr.data[s] = ret_conv_18_conv;
        }
@@ -7551,13 +7914,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvide
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
        LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
-               *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
+               *ret_conv_18_copy = ret_var.data[s];
                uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
                ret_arr_ptr[s] = ret_conv_18_ref;
        }
@@ -7638,7 +8004,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv
        return (uint64_t)res_ptr;
 }
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
        LDKEvent* event_conv = (LDKEvent*)event;
        (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
 }
@@ -7675,7 +8043,7 @@ void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEve
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+       LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *handler_ret = handler;
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
@@ -7715,8 +8083,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIE
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
-       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
-       LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
+       void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
+       CHECK_ACCESS(handler_ptr);
+       LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
        if (handler_conv.free == LDKEventHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKEventHandler_JCalls_cloned(&handler_conv);
@@ -7823,7 +8195,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env,
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        LDKu8slice block_ref;
        block_ref.datalen = (*env)->GetArrayLength(env, block);
        block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
@@ -7832,7 +8206,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEn
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -7878,7 +8254,8 @@ void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t
        int8_tArray header_arr = (*env)->NewByteArray(env, 80);
        (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
        LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
-       int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
+       int64_tArray txdata_arr = NULL;
+       txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
        int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
        for (size_t c = 0; c < txdata_var.datalen; c++) {
                LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
@@ -8012,7 +8389,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -8026,7 +8405,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirm
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
@@ -8035,7 +8416,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirm
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
@@ -8044,7 +8427,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfir
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -8053,15 +8438,19 @@ 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 *env, jclass clz, int64_t this_arg) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        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);
+       jobjectArray ret_arr = NULL;
+       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;
 }
@@ -8090,7 +8479,7 @@ static void LDKPersist_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -8099,36 +8488,48 @@ LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(con
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((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_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -8137,37 +8538,52 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcal
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = *update;
-       update_var = ChannelMonitorUpdate_clone(update);
-       CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
-       CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
-       if (update_var.is_owned) {
-               update_ref |= 1;
+       uint64_t update_ref = 0;
+       if ((uint64_t)update_var.inner > 4096) {
+               update_var = ChannelMonitorUpdate_clone(update);
+               CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               update_ref = (uint64_t)update_var.inner;
+               if (update_var.is_owned) {
+                       update_ref |= 1;
+               }
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -8185,9 +8601,9 @@ static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
        atomic_init(&calls->refcnt, 1);
        DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
        calls->o = (*env)->NewWeakGlobalRef(env, o);
-       calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
+       calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
        CHECK(calls->persist_new_channel_meth != NULL);
-       calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
+       calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
        CHECK(calls->update_persisted_channel_meth != NULL);
 
        LDKPersist ret = {
@@ -8203,34 +8619,46 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env
        *res_ptr = LDKPersist_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitorUpdate update_conv;
        update_conv.inner = (void*)(update & (~1));
        update_conv.is_owned = false;
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
@@ -8289,17 +8717,19 @@ void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LD
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKOpenChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = OpenChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8326,17 +8756,19 @@ void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKAcceptChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AcceptChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8363,10 +8795,11 @@ void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingCreated msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingCreated_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8393,10 +8826,11 @@ void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8423,10 +8857,11 @@ void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingLocked msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingLocked_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8453,18 +8888,20 @@ void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPub
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = *their_features;
+       uint64_t their_features_ref = 0;
        their_features_var = InitFeatures_clone(their_features);
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKShutdown msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Shutdown_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8491,10 +8928,11 @@ void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKClosingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ClosingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8521,10 +8959,11 @@ void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateAddHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateAddHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8551,10 +8990,11 @@ void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFulfillHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFulfillHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8581,10 +9021,11 @@ void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFailHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8611,10 +9052,11 @@ void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFailMalformedHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailMalformedHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8641,10 +9083,11 @@ void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_ar
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKCommitmentSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = CommitmentSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8671,10 +9114,11 @@ void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKRevokeAndACK msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = RevokeAndACK_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8701,10 +9145,11 @@ void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKP
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFee msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFee_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8731,10 +9176,11 @@ void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* t
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKAnnouncementSignatures msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AnnouncementSignatures_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8783,10 +9229,11 @@ void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPubl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInit msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Init_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8813,10 +9260,11 @@ void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKChannelReestablish msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelReestablish_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8843,10 +9291,11 @@ void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8873,10 +9322,11 @@ void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublic
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKErrorMessage msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ErrorMessage_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8984,7 +9434,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1g
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -8999,7 +9451,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9014,7 +9468,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9025,7 +9481,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9036,7 +9494,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9047,7 +9507,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9061,7 +9523,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9072,7 +9536,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9083,7 +9549,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9094,7 +9562,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9105,7 +9575,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9116,7 +9588,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9127,7 +9601,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9138,7 +9614,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9149,7 +9627,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9160,7 +9640,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9168,7 +9650,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1d
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9179,7 +9663,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1c
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9190,7 +9676,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9201,7 +9689,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9254,10 +9744,11 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKNodeAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = NodeAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9268,7 +9759,9 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9285,10 +9778,11 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHand
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9299,7 +9793,9 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHand
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9316,10 +9812,11 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9330,7 +9827,9 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9362,7 +9861,9 @@ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t h = 0; h < ret_constr.datalen; h++) {
                int64_t ret_conv_59 = ret_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
+               void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
+               CHECK_ACCESS(ret_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
                ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
                ret_constr.data[h] = ret_conv_59_conv;
        }
@@ -9423,10 +9924,11 @@ void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDK
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInit init_var = *init;
+       uint64_t init_ref = 0;
        init_var = Init_clone(init);
        CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t init_ref = (uint64_t)init_var.inner;
+       init_ref = (uint64_t)init_var.inner;
        if (init_var.is_owned) {
                init_ref |= 1;
        }
@@ -9453,9 +9955,10 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKReplyChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9466,7 +9969,9 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9485,9 +9990,10 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKReplyShortChannelIdsEnd msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9498,7 +10004,9 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9517,9 +10025,10 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKQueryChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9530,7 +10039,9 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9549,9 +10060,10 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKQueryShortChannelIds msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9562,7 +10074,9 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9632,7 +10146,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1g
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKNodeAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9642,7 +10158,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9652,7 +10170,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelUpdate msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9662,9 +10182,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
@@ -9677,18 +10200,22 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_18_ref = 0;
                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;
+               ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
                if (ret_conv_18_var.is_owned) {
                        ret_conv_18_ref |= 1;
                }
@@ -9700,7 +10227,9 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9711,7 +10240,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1r
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9725,7 +10256,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9739,7 +10272,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9753,7 +10288,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9808,7 +10345,9 @@ LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const voi
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
        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);
@@ -9842,7 +10381,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
        LDKu8slice buffer_ref;
        buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
        buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
@@ -9886,7 +10427,7 @@ LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jca
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
+       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);
@@ -9897,7 +10438,9 @@ LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jca
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9929,7 +10472,9 @@ LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandle
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t z = 0; z < ret_constr.datalen; z++) {
                int64_t ret_conv_25 = ret_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
+               void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
+               CHECK_ACCESS(ret_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
                ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
                ret_constr.data[z] = ret_conv_25_conv;
        }
@@ -9978,8 +10523,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1ge
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+       void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
+       CHECK_ACCESS(msg_ptr);
+       LDKType msg_conv = *(LDKType*)(msg_ptr);
        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);
@@ -9993,9 +10542,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handl
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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++) {
                LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
@@ -10158,7 +10710,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JN
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = (*env)->GetArrayLength(env, data);
        data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
@@ -10168,12 +10722,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1dat
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
        return ret_val;
 }
@@ -10183,6 +10741,8 @@ typedef struct LDKScore_JCalls {
        JavaVM *vm;
        jweak o;
        jmethodID channel_penalty_msat_meth;
+       jmethodID payment_path_failed_meth;
+       jmethodID write_meth;
 } LDKScore_JCalls;
 static void LDKScore_JCalls_free(void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
@@ -10201,7 +10761,7 @@ static void LDKScore_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
+uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -10210,9 +10770,27 @@ uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t shor
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
+       LDKNodeId source_var = *source;
+       uint64_t source_ref = 0;
+       source_var = NodeId_clone(source);
+       CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       source_ref = (uint64_t)source_var.inner;
+       if (source_var.is_owned) {
+               source_ref |= 1;
+       }
+       LDKNodeId target_var = *target;
+       uint64_t target_ref = 0;
+       target_var = NodeId_clone(target);
+       CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       target_ref = (uint64_t)target_var.inner;
+       if (target_var.is_owned) {
+               target_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id);
+       int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
@@ -10222,6 +10800,68 @@ uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t shor
        }
        return ret;
 }
+void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+       LDKScore_JCalls *j_calls = (LDKScore_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);
+       }
+       LDKCVec_RouteHopZ path_var = path;
+       int64_tArray path_arr = NULL;
+       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];
+               uint64_t path_conv_10_ref = 0;
+               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.
+               path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
+               if (path_conv_10_var.is_owned) {
+                       path_conv_10_ref |= 1;
+               }
+               path_arr_ptr[k] = path_conv_10_ref;
+       }
+       (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
+       FREE(path_var.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
+       }
+       if (get_jenv_res == JNI_EDETACHED) {
+               DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+       }
+}
+LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
+       LDKScore_JCalls *j_calls = (LDKScore_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 LDKScore 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 LDKScore_JCalls_cloned(LDKScore* new_obj) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
        atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
@@ -10233,12 +10873,18 @@ static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
        atomic_init(&calls->refcnt, 1);
        DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
        calls->o = (*env)->NewWeakGlobalRef(env, o);
-       calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(J)J");
+       calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJ)J");
        CHECK(calls->channel_penalty_msat_meth != NULL);
+       calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
+       CHECK(calls->payment_path_failed_meth != NULL);
+       calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
+       CHECK(calls->write_meth != NULL);
 
        LDKScore ret = {
                .this_arg = (void*) calls,
                .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
+               .payment_path_failed = payment_path_failed_LDKScore_jcall,
+               .write = write_LDKScore_jcall,
                .free = LDKScore_JCalls_free,
        };
        return ret;
@@ -10248,12 +10894,54 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env,
        *res_ptr = LDKScore_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
-       LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
-       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       LDKNodeId source_conv;
+       source_conv.inner = (void*)(source & (~1));
+       source_conv.is_owned = false;
+       LDKNodeId target_conv;
+       target_conv.inner = (void*)(target & (~1));
+       target_conv.is_owned = false;
+       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
        return ret_val;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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);
+       (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+}
+
 typedef struct LDKChannelManagerPersister_JCalls {
        atomic_size_t refcnt;
        JavaVM *vm;
@@ -10287,10 +10975,11 @@ LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const voi
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelManager channel_manager_var = *channel_manager;
+       uint64_t channel_manager_ref = 0;
        // Warning: we may need a move here but no clone is available for LDKChannelManager
        CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
+       channel_manager_ref = (uint64_t)channel_manager_var.inner;
        if (channel_manager_var.is_owned) {
                channel_manager_ref |= 1;
        }
@@ -10301,7 +10990,9 @@ LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const voi
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
        }
-       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -10335,7 +11026,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
-       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
        LDKChannelManager channel_manager_conv;
        channel_manager_conv.inner = (void*)(channel_manager & (~1));
        channel_manager_conv.is_owned = false;
@@ -10390,44 +11083,452 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr
                default: abort();
        }
 }
-JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
-       LDKStr ret_str = _ldk_get_compiled_version();
-       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
-       Str_free(ret_str);
-       return ret_conv;
-}
-
-JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
-       LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
-       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
-       Str_free(ret_str);
-       return ret_conv;
+typedef struct LDKPayer_JCalls {
+       atomic_size_t refcnt;
+       JavaVM *vm;
+       jweak o;
+       jmethodID node_id_meth;
+       jmethodID first_hops_meth;
+       jmethodID send_payment_meth;
+       jmethodID retry_payment_meth;
+} LDKPayer_JCalls;
+static void LDKPayer_JCalls_free(void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
 }
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
-       LDKTransaction _res_ref;
-       _res_ref.datalen = (*env)->GetArrayLength(env, _res);
-       _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
-       (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
-       _res_ref.data_is_owned = true;
-       Transaction_free(_res_ref);
+LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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->node_id_meth);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
+       }
+       LDKPublicKey ret_ref;
+       CHECK((*env)->GetArrayLength(env, ret) == 33);
+       (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
+       if (get_jenv_res == JNI_EDETACHED) {
+               DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+       }
+       return ret_ref;
 }
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
-       LDKCVec_u8Z script_pubkey_ref;
-       script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
-       script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
-       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
-       *ret_ref = TxOut_new(script_pubkey_ref, value);
-       return (uint64_t)ret_ref;
+LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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->first_hops_meth);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
+       }
+       LDKCVec_ChannelDetailsZ ret_constr;
+       ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+       if (ret_constr.datalen > 0)
+               ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               ret_constr.data = NULL;
+       int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+       for (size_t q = 0; q < ret_constr.datalen; q++) {
+               int64_t ret_conv_16 = ret_vals[q];
+               LDKChannelDetails ret_conv_16_conv;
+               ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
+               ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
+               ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
+               ret_constr.data[q] = ret_conv_16_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;
 }
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       TxOut_free(_res_conv);
+LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
+       int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((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_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((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 LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
+       jclass c = (*env)->GetObjectClass(env, o);
+       CHECK(c != NULL);
+       LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+       calls->o = (*env)->NewWeakGlobalRef(env, o);
+       calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
+       CHECK(calls->node_id_meth != NULL);
+       calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
+       CHECK(calls->first_hops_meth != NULL);
+       calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
+       CHECK(calls->send_payment_meth != NULL);
+       calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
+       CHECK(calls->retry_payment_meth != NULL);
+
+       LDKPayer ret = {
+               .this_arg = (void*) calls,
+               .node_id = node_id_LDKPayer_jcall,
+               .first_hops = first_hops_LDKPayer_jcall,
+               .send_payment = send_payment_LDKPayer_jcall,
+               .retry_payment = retry_payment_LDKPayer_jcall,
+               .free = LDKPayer_JCalls_free,
+       };
+       return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
+       LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *res_ptr = LDKPayer_init(env, clz, o);
+       return (uint64_t)res_ptr;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
+       int64_tArray ret_arr = NULL;
+       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++) {
+               LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
+               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.
+               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 int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_hash_ref;
+       CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
+       (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
+       LDKThirtyTwoBytes payment_secret_ref;
+       CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
+       (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
+       LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
+       LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
+       return (uint64_t)ret_conv;
+}
+
+typedef struct LDKRouter_JCalls {
+       atomic_size_t refcnt;
+       JavaVM *vm;
+       jweak o;
+       jmethodID find_route_meth;
+} LDKRouter_JCalls;
+static void LDKRouter_JCalls_free(void* this_arg) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_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_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_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 payer_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
+       LDKRouteParameters params_var = *params;
+       uint64_t params_ref = 0;
+       params_var = RouteParameters_clone(params);
+       CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       params_ref = (uint64_t)params_var.inner;
+       if (params_var.is_owned) {
+               params_ref |= 1;
+       }
+       LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
+       int64_tArray first_hops_arr = NULL;
+       if (first_hops != NULL) {
+               LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
+               first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
+               int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
+               for (size_t q = 0; q < first_hops_var.datalen; q++) {
+                       LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
+                       uint64_t first_hops_conv_16_ref = 0;
+                       CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
+                       if (first_hops_conv_16_var.is_owned) {
+                               first_hops_conv_16_ref |= 1;
+                       }
+                       first_hops_arr_ptr[q] = first_hops_conv_16_ref;
+               }
+               (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
+       }
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_scorer = ((uint64_t)scorer) | 1;
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
+       ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((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 LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
+       jclass c = (*env)->GetObjectClass(env, o);
+       CHECK(c != NULL);
+       LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+       calls->o = (*env)->NewWeakGlobalRef(env, o);
+       calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
+       CHECK(calls->find_route_meth != NULL);
+
+       LDKRouter ret = {
+               .this_arg = (void*) calls,
+               .find_route = find_route_LDKRouter_jcall,
+               .free = LDKRouter_JCalls_free,
+       };
+       return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
+       LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *res_ptr = LDKRouter_init(env, clz, o);
+       return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t params, int64_tArray first_hops, int64_t scorer) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
+       LDKPublicKey payer_ref;
+       CHECK((*env)->GetArrayLength(env, payer) == 33);
+       (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
+       LDKCVec_ChannelDetailsZ first_hops_constr;
+       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
+       if (first_hops != NULL) {
+               first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
+               if (first_hops_constr.datalen > 0)
+                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+               else
+                       first_hops_constr.data = NULL;
+               int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
+               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
+                       int64_t first_hops_conv_16 = first_hops_vals[q];
+                       LDKChannelDetails first_hops_conv_16_conv;
+                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
+                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
+                       first_hops_constr.data[q] = first_hops_conv_16_conv;
+               }
+               (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
+               first_hops_ptr = &first_hops_constr;
+       }
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
+       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
+       *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
+       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
+       LDKStr ret_str = _ldk_get_compiled_version();
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
+       LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
+       LDKTransaction _res_ref;
+       _res_ref.datalen = (*env)->GetArrayLength(env, _res);
+       _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
+       (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
+       _res_ref.data_is_owned = true;
+       Transaction_free(_res_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
+       LDKCVec_u8Z script_pubkey_ref;
+       script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
+       script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
+       (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
+       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+       *ret_ref = TxOut_new(script_pubkey_ref, value);
+       return (uint64_t)ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
+       FREE((void*)_res);
+       TxOut_free(_res_conv);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
@@ -10460,7 +11561,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SecretKeyErrorZ_free(_res_conv);
 }
@@ -10483,7 +11586,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PublicKeyErrorZ_free(_res_conv);
 }
@@ -10517,7 +11622,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
 }
@@ -10551,7 +11658,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
 }
@@ -10582,7 +11691,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysErrorZ_free(_res_conv);
 }
@@ -10610,7 +11721,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u32Z_free(_res_conv);
 }
@@ -10645,7 +11758,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommit
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
 }
@@ -10679,7 +11794,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChanne
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -10713,7 +11830,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransaction
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -10764,7 +11883,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10798,7 +11919,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTra
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10828,7 +11951,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTran
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
 }
@@ -10855,7 +11980,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransact
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10885,7 +12012,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentT
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
 }
@@ -10917,7 +12046,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
@@ -10951,7 +12082,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
 }
@@ -10977,7 +12110,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInva
        LDKInvalidShutdownScript e_conv;
        e_conv.inner = (void*)(e & (~1));
        e_conv.is_owned = (e & 1) || (e == 0);
-       // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
+       e_conv = InvalidShutdownScript_clone(&e_conv);
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
        *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
        return (uint64_t)ret_conv;
@@ -10985,11 +12118,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInva
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
+       *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
        LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
        *ret_conv = CResult_NoneErrorZ_ok();
@@ -11005,7 +12147,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JN
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneErrorZ_free(_res_conv);
 }
@@ -11039,7 +12183,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteHopDecodeErrorZ_free(_res_conv);
 }
@@ -11121,7 +12267,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteDecodeErrorZ_free(_res_conv);
 }
@@ -11133,52 +12281,40 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_some(o);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteParameters o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteParameters_clone(&o_conv);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_none();
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
-       COption_u64Z_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_clone(orig_conv);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+       CResult_RouteParametersDecodeErrorZ_free(_res_conv);
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
-       LDKCVec_ChannelDetailsZ _res_constr;
-       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
-       if (_res_constr.datalen > 0)
-               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-       else
-               _res_constr.data = NULL;
-       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
-       for (size_t q = 0; q < _res_constr.datalen; q++) {
-               int64_t _res_conv_16 = _res_vals[q];
-               LDKChannelDetails _res_conv_16_conv;
-               _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
-               _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
-               _res_constr.data[q] = _res_conv_16_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
-       CVec_ChannelDetailsZ_free(_res_constr);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
@@ -11200,11 +12336,188 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv
        CVec_RouteHintZ_free(_res_constr);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKRoute o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = Route_clone(&o_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_some(o);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_none();
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
+       FREE((void*)_res);
+       COption_u64Z_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Payee_clone(&o_conv);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PayeeDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
+       LDKCVec_RouteHintHopZ _res_constr;
+       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               _res_constr.data = NULL;
+       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
+       for (size_t o = 0; o < _res_constr.datalen; o++) {
+               int64_t _res_conv_14 = _res_vals[o];
+               LDKRouteHintHop _res_conv_14_conv;
+               _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
+               _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
+               _res_constr.data[o] = _res_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
+       CVec_RouteHintHopZ_free(_res_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteHint o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHint_clone(&o_conv);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteHintHop o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHintHop_clone(&o_conv);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
+       LDKCVec_ChannelDetailsZ _res_constr;
+       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               _res_constr.data = NULL;
+       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
+       for (size_t q = 0; q < _res_constr.datalen; q++) {
+               int64_t _res_conv_16 = _res_vals[q];
+               LDKChannelDetails _res_conv_16_conv;
+               _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
+               _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
+               _res_constr.data[q] = _res_conv_16_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
+       CVec_ChannelDetailsZ_free(_res_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRoute o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Route_clone(&o_conv);
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
        *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
        return (uint64_t)ret_conv;
@@ -11222,7 +12535,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteLightningErrorZ_free(_res_conv);
 }
@@ -11235,7 +12550,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
        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);
@@ -11251,7 +12568,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxOutAccessErrorZ_free(_res_conv);
 }
@@ -11283,7 +12602,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_usizeTransactionZ_free(_res_conv);
 }
@@ -11298,7 +12619,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactio
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t c = 0; c < _res_constr.datalen; c++) {
                int64_t _res_conv_28 = _res_vals[c];
-               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
+               void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
+               CHECK_ACCESS(_res_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
                FREE((void*)_res_conv_28);
                _res_constr.data[c] = _res_conv_28_conv;
        }
@@ -11338,7 +12661,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitor
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
 }
@@ -11360,7 +12685,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIE
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                int64_t _res_conv_14 = _res_vals[o];
-               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
+               void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
+               CHECK_ACCESS(_res_conv_14_ptr);
+               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
                FREE((void*)_res_conv_14);
                _res_constr.data[o] = _res_conv_14_conv;
        }
@@ -11369,7 +12696,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
        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);
@@ -11386,7 +12715,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
 }
@@ -11400,7 +12731,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
        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);
@@ -11417,7 +12750,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1no
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        COption_NetworkUpdateZ_free(_res_conv);
 }
@@ -11440,7 +12775,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescripto
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t b = 0; b < _res_constr.datalen; b++) {
                int64_t _res_conv_27 = _res_vals[b];
-               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
+               void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
+               CHECK_ACCESS(_res_conv_27_ptr);
+               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
                FREE((void*)_res_conv_27);
                _res_constr.data[b] = _res_conv_27_conv;
        }
@@ -11458,7 +12795,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t s = 0; s < _res_constr.datalen; s++) {
                int64_t _res_conv_18 = _res_vals[s];
-               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
+               void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
+               CHECK_ACCESS(_res_conv_18_ptr);
+               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
                FREE((void*)_res_conv_18);
                _res_constr.data[s] = _res_conv_18_conv;
        }
@@ -11488,7 +12827,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11515,7 +12856,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11542,7 +12885,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDec
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11569,11 +12914,71 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDec
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKScoringParameters 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 LDKScoringParameters
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKScorer 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 LDKScorer
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScorerDecodeErrorZ_free(_res_conv);
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
        LDKDelayedPaymentOutputDescriptor o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -11596,7 +13001,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutp
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11630,7 +13037,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutpu
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11643,7 +13052,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
        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);
@@ -11662,7 +13073,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDes
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11688,7 +13101,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNI
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneNoneZ_free(_res_conv);
 }
@@ -11731,13 +13146,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1Sig
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
        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);
@@ -11752,7 +13171,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1Signature
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
@@ -11781,7 +13202,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1er
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignatureNoneZ_free(_res_conv);
 }
@@ -11794,7 +13217,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1cl
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSign o_conv = *(LDKSign*)(o_ptr);
        if (o_conv.free == LDKSign_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSign_JCalls_cloned(&o_conv);
@@ -11816,7 +13241,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignDecodeErrorZ_free(_res_conv);
 }
@@ -11853,7 +13280,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatu
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RecoverableSignatureNoneZ_free(_res_conv);
 }
@@ -11911,7 +13340,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
 }
@@ -11945,7 +13376,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
 }
@@ -11967,7 +13400,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_7 = _res_vals[h];
-               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -11994,7 +13429,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TransactionNoneZ_free(_res_conv);
 }
@@ -12028,7 +13465,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
 }
@@ -12043,7 +13482,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChanne
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t j = 0; j < _res_constr.datalen; j++) {
                int64_t _res_conv_35 = _res_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
+               void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
+               CHECK_ACCESS(_res_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
                FREE((void*)_res_conv_35);
                _res_constr.data[j] = _res_conv_35_conv;
        }
@@ -12061,7 +13502,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
        int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
        for (size_t j = 0; j < o_constr.datalen; j++) {
                int64_t o_conv_35 = o_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
+               void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
+               CHECK_ACCESS(o_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
                o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
                o_constr.data[j] = o_conv_35_conv;
        }
@@ -12080,7 +13523,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
 }
@@ -12092,40 +13537,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_PaymentIdDecodeErrorZ_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
        LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
        *ret_copy = COption_u16Z_some(o);
@@ -12142,7 +13553,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u16Z_free(_res_conv);
 }
@@ -12162,7 +13575,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -12171,7 +13586,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneAPIErrorZ_free(_res_conv);
 }
@@ -12193,7 +13610,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t w = 0; w < _res_constr.datalen; w++) {
                int64_t _res_conv_22 = _res_vals[w];
-               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
+               void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
+               CHECK_ACCESS(_res_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
                FREE((void*)_res_conv_22);
                _res_constr.data[w] = _res_conv_22_conv;
        }
@@ -12211,7 +13630,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t k = 0; k < _res_constr.datalen; k++) {
                int64_t _res_conv_10 = _res_vals[k];
-               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
+               void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
+               CHECK_ACCESS(_res_conv_10_ptr);
+               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
                FREE((void*)_res_conv_10);
                _res_constr.data[k] = _res_conv_10_conv;
        }
@@ -12229,7 +13650,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1o
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
        LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
        *ret_conv = CResult__u832APIErrorZ_err(e_conv);
@@ -12238,7 +13661,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult__u832APIErrorZ_free(_res_conv);
 }
@@ -12250,18 +13675,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1c
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK((*env)->GetArrayLength(env, o) == 32);
+       (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
-       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
+       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
        return (uint64_t)ret_conv;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
        *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
@@ -12270,7 +13696,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
 }
@@ -12289,7 +13717,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        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);
@@ -12298,7 +13728,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFai
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePaymentSendFailureZ_free(_res_conv);
 }
@@ -12317,28 +13749,31 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPayment
        return ((uint64_t)ret_conv);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
        LDKThirtyTwoBytes a_ref;
        CHECK((*env)->GetArrayLength(env, a) == 32);
        (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
+       LDKThirtyTwoBytes b_ref;
+       CHECK((*env)->GetArrayLength(env, b) == 32);
+       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
        LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
+       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
        return ((uint64_t)ret_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
        o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
@@ -12346,7 +13781,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHa
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
@@ -12355,7 +13792,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
 }
@@ -12377,7 +13816,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t m = 0; m < _res_constr.datalen; m++) {
                int64_t _res_conv_12 = _res_vals[m];
-               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
+               void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
+               CHECK_ACCESS(_res_conv_12_ptr);
+               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
                FREE((void*)_res_conv_12);
                _res_constr.data[m] = _res_conv_12_conv;
        }
@@ -12406,7 +13847,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPayment
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
 }
@@ -12421,7 +13864,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -12430,7 +13875,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentSecretAPIErrorZ_free(_res_conv);
 }
@@ -12476,13 +13923,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
        // 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);
@@ -12501,7 +13952,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHash
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
 }
@@ -12528,7 +13981,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
 }
@@ -12562,7 +14017,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OutPointDecodeErrorZ_free(_res_conv);
 }
@@ -12575,7 +14032,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKType o_conv = *(LDKType*)(o_ptr);
        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);
@@ -12595,7 +14054,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
        FREE((void*)_res);
        COption_TypeZ_free(_res_conv);
 }
@@ -12609,7 +14070,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEn
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
        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);
@@ -12628,7 +14091,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDeco
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
 }
@@ -12640,6 +14105,41 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDeco
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK((*env)->GetArrayLength(env, o) == 32);
+       (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
+       e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PaymentIdPaymentErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_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");
@@ -12655,7 +14155,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SiPrefixNoneZ_free(_res_conv);
 }
@@ -12685,7 +14187,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceNoneZ_free(_res_conv);
 }
@@ -12715,7 +14219,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignedRawInvoiceNoneZ_free(_res_conv);
 }
@@ -12753,7 +14259,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832In
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
 }
@@ -12777,7 +14285,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PayeePubKeyErrorZ_free(_res_conv);
 }
@@ -12827,7 +14337,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampC
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
 }
@@ -12854,7 +14366,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneSemanticErrorZ_free(_res_conv);
 }
@@ -12885,7 +14399,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSemanticErrorZ_free(_res_conv);
 }
@@ -12916,7 +14432,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreatio
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DescriptionCreationErrorZ_free(_res_conv);
 }
@@ -12947,7 +14465,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreation
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
 }
@@ -12978,7 +14498,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreati
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PrivateRouteCreationErrorZ_free(_res_conv);
 }
@@ -13006,7 +14528,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StringErrorZ_free(_res_conv);
 }
@@ -13033,7 +14557,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpda
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -13067,7 +14593,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -13097,7 +14625,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
 }
@@ -13132,7 +14662,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1n
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_OutPointScriptZ_free(_res_conv);
 }
@@ -13156,7 +14688,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JN
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32ScriptZ_free(_res_conv);
 }
@@ -13171,7 +14705,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1fr
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t v = 0; v < _res_constr.datalen; v++) {
                int64_t _res_conv_21 = _res_vals[v];
-               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
+               void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
+               CHECK_ACCESS(_res_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
                FREE((void*)_res_conv_21);
                _res_constr.data[v] = _res_conv_21_conv;
        }
@@ -13199,7 +14735,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
        int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
        for (size_t v = 0; v < b_constr.datalen; v++) {
                int64_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
+               void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
+               CHECK_ACCESS(b_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
                b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
                b_constr.data[v] = b_conv_21_conv;
        }
@@ -13211,7 +14749,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
 }
@@ -13226,7 +14766,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                int64_t _res_conv_40 = _res_vals[o];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
+               void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
+               CHECK_ACCESS(_res_conv_40_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
                FREE((void*)_res_conv_40);
                _res_constr.data[o] = _res_conv_40_conv;
        }
@@ -13244,7 +14786,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_7 = _res_vals[h];
-               LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -13279,7 +14823,9 @@ 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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
        b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
        LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
@@ -13288,7 +14834,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32TxOutZ_free(_res_conv);
 }
@@ -13303,7 +14851,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1fre
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t u = 0; u < _res_constr.datalen; u++) {
                int64_t _res_conv_20 = _res_vals[u];
-               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
+               void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
+               CHECK_ACCESS(_res_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
                FREE((void*)_res_conv_20);
                _res_constr.data[u] = _res_conv_20_conv;
        }
@@ -13331,7 +14881,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
        int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
        for (size_t u = 0; u < b_constr.datalen; u++) {
                int64_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
+               void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
+               CHECK_ACCESS(b_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
                b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
                b_constr.data[u] = b_conv_20_conv;
        }
@@ -13343,7 +14895,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
 }
@@ -13358,7 +14912,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t n = 0; n < _res_constr.datalen; n++) {
                int64_t _res_conv_39 = _res_vals[n];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
+               void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
+               CHECK_ACCESS(_res_conv_39_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
                FREE((void*)_res_conv_39);
                _res_constr.data[n] = _res_conv_39_conv;
        }
@@ -13376,7 +14932,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *e
        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);
+               void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
+               CHECK_ACCESS(_res_conv_9_ptr);
+               LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
                FREE((void*)_res_conv_9);
                _res_constr.data[j] = _res_conv_9_conv;
        }
@@ -13385,7 +14943,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *e
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
        o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
@@ -13404,7 +14964,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHash
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
 }
@@ -13434,7 +14996,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningError
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneLightningErrorZ_free(_res_conv);
 }
@@ -13457,7 +15021,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1ne
        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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKType b_conv = *(LDKType*)(b_ptr);
        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);
@@ -13469,7 +15035,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1ne
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PublicKeyTypeZ_free(_res_conv);
 }
@@ -13484,7 +15052,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t z = 0; z < _res_constr.datalen; z++) {
                int64_t _res_conv_25 = _res_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
+               void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
+               CHECK_ACCESS(_res_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
                FREE((void*)_res_conv_25);
                _res_constr.data[z] = _res_conv_25_conv;
        }
@@ -13510,7 +15080,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningError
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolLightningErrorZ_free(_res_conv);
 }
@@ -13549,7 +15121,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncemen
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
 }
@@ -13564,7 +15138,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnounce
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_59 = _res_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
+               void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
+               CHECK_ACCESS(_res_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
                FREE((void*)_res_conv_59);
                _res_constr.data[h] = _res_conv_59_conv;
        }
@@ -13630,7 +15206,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandl
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
 }
@@ -13660,7 +15238,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePeerHandleErrorZ_free(_res_conv);
 }
@@ -13690,7 +15270,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolPeerHandleErrorZ_free(_res_conv);
 }
@@ -13724,7 +15306,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeIdDecodeErrorZ_free(_res_conv);
 }
@@ -13737,7 +15321,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKAccess o_conv = *(LDKAccess*)(o_ptr);
        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);
@@ -13757,7 +15343,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
        FREE((void*)_res);
        COption_AccessZ_free(_res_conv);
 }
@@ -13784,7 +15372,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannel
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13818,7 +15408,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13852,7 +15444,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
 }
@@ -13886,7 +15480,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementIn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13936,7 +15532,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13970,7 +15568,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
 }
@@ -13992,7 +15592,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
        int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
        for (size_t m = 0; m < o_constr.datalen; m++) {
                int64_t o_conv_12 = o_vals[m];
-               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
+               void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
+               CHECK_ACCESS(o_conv_12_ptr);
+               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
                o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
                o_constr.data[m] = o_conv_12_conv;
        }
@@ -14012,7 +15614,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_CVec_NetAddressZZ_free(_res_conv);
 }
@@ -14025,68 +15629,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
        return ret_ref;
 }
 
-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;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_err(e);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_NetAddressu8Z_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
-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;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
        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);
@@ -14105,7 +15651,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetAddressDecodeErrorZ_free(_res_conv);
 }
@@ -14215,7 +15763,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
 }
@@ -14249,7 +15799,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignat
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
 }
@@ -14283,7 +15835,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablish
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
 }
@@ -14317,7 +15871,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14351,7 +15907,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
 }
@@ -14385,7 +15943,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14419,7 +15979,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
 }
@@ -14453,7 +16015,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14487,7 +16051,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingLockedDecodeErrorZ_free(_res_conv);
 }
@@ -14521,7 +16087,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitDecodeErrorZ_free(_res_conv);
 }
@@ -14555,7 +16123,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OpenChannelDecodeErrorZ_free(_res_conv);
 }
@@ -14589,7 +16159,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
 }
@@ -14623,7 +16195,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownDecodeErrorZ_free(_res_conv);
 }
@@ -14657,7 +16231,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14691,7 +16267,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalforme
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14725,7 +16303,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
 }
@@ -14759,7 +16339,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14793,7 +16375,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14827,7 +16411,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PingDecodeErrorZ_free(_res_conv);
 }
@@ -14861,7 +16447,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PongDecodeErrorZ_free(_res_conv);
 }
@@ -14895,7 +16483,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -14929,7 +16519,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncemen
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -14963,7 +16555,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpd
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -14997,7 +16591,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -15031,7 +16627,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
 }
@@ -15065,7 +16663,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnoun
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -15099,7 +16699,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -15133,7 +16735,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
 }
@@ -15167,7 +16771,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
 }
@@ -15201,7 +16807,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -15235,7 +16843,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -15269,7 +16879,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFil
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
 }
@@ -15292,7 +16904,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
        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);
@@ -15301,7 +16915,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
 }
@@ -15314,7 +16930,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKFilter o_conv = *(LDKFilter*)(o_ptr);
        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);
@@ -15334,7 +16952,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
        FREE((void*)_res);
        COption_FilterZ_free(_res_conv);
 }
@@ -15357,7 +16977,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonit
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_LockedChannelMonitorNoneZ_free(_res_conv);
 }
@@ -15383,7 +17005,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentPurpose_free(this_ptr_conv);
 }
@@ -15421,7 +17045,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ClosureReason_free(this_ptr_conv);
 }
@@ -15496,7 +17122,9 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JN
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Event_free(this_ptr_conv);
 }
@@ -15527,7 +17155,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
+       CHECK_ACCESS(purpose_ptr);
+       LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
        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);
@@ -15535,24 +17165,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN
        return ret_ref;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_hash) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKThirtyTwoBytes payment_preimage_ref;
        CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
        (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
        LDKThirtyTwoBytes payment_hash_ref;
        CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
        (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
+       void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
+       CHECK_ACCESS(fee_paid_msat_ptr);
+       LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
+       fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
+       *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-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, int64_t short_channel_id) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        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);
+       void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
+       CHECK_ACCESS(network_update_ptr);
+       LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
        network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
        LDKCVec_RouteHopZ path_constr;
        path_constr.datalen = (*env)->GetArrayLength(env, path);
@@ -15570,10 +17212,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1faile
                path_constr.data[k] = path_conv_10_conv;
        }
        (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
-       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
+       void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
+       CHECK_ACCESS(short_channel_id_ptr);
+       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
        short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
+       LDKRouteParameters retry_conv;
+       retry_conv.inner = (void*)(retry & (~1));
+       retry_conv.is_owned = (retry & 1) || (retry == 0);
+       retry_conv = RouteParameters_clone(&retry_conv);
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
+       *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -15595,7 +17243,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(J
        int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
        for (size_t b = 0; b < outputs_constr.datalen; b++) {
                int64_t outputs_conv_27 = outputs_vals[b];
-               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
+               void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
+               CHECK_ACCESS(outputs_conv_27_ptr);
+               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
                outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
                outputs_constr.data[b] = outputs_conv_27_conv;
        }
@@ -15607,7 +17257,9 @@ 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);
+       void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
+       CHECK_ACCESS(fee_earned_msat_ptr);
+       LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
        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);
@@ -15619,7 +17271,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIE
        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);
+       void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
+       CHECK_ACCESS(reason_ptr);
+       LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
        reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
        *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
@@ -15653,7 +17307,9 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *en
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEvent_free(this_ptr_conv);
 }
@@ -15875,7 +17531,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1e
        LDKPublicKey node_id_ref;
        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);
+       void* action_ptr = (void*)(((uint64_t)action) & ~1);
+       CHECK_ACCESS(action_ptr);
+       LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
        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);
@@ -15927,28 +17585,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1rep
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEventsProvider_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventsProvider_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventHandler_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        APIError_free(this_ptr_conv);
 }
@@ -16100,7 +17766,9 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jcla
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Logger_free(this_ptr_conv);
 }
@@ -16159,9 +17827,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1o
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16173,9 +17842,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16184,9 +17854,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16322,9 +17993,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1t
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16336,9 +18008,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16347,9 +18020,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16470,9 +18144,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
        LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16484,9 +18159,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16495,9 +18171,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
        LDKChannelConfig ret_var = ChannelConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16537,9 +18214,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1chann
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16562,9 +18240,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1chan
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16587,9 +18266,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1o
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16636,9 +18316,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env
        channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
        channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
        LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16650,9 +18331,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16661,9 +18343,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *e
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
        LDKUserConfig ret_var = UserConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16682,9 +18365,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *en
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16694,9 +18378,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *en
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
        LDKNetwork network_conv = LDKNetwork_from_java(env, network);
        LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16708,9 +18393,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, block_hash) == 32);
        (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
        LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16752,21 +18438,27 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Access_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Listen_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Confirm_free(this_ptr_conv);
 }
@@ -16789,14 +18481,18 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1per
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Watch_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Filter_free(this_ptr_conv);
 }
@@ -16832,9 +18528,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16886,9 +18583,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1new(JNIEnv *
        script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
        LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16900,9 +18598,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16919,7 +18618,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BroadcasterInterface_free(this_ptr_conv);
 }
@@ -16954,34 +18655,81 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        FeeEstimator_free(this_ptr_conv);
 }
 
-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);
-       FREE((void*)this_ptr);
-       Persist_free(this_ptr_conv);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKLockedChannelMonitor this_obj_conv;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKMonitorUpdateId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       LockedChannelMonitor_free(this_obj_conv);
+       MonitorUpdateId_free(this_obj_conv);
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKChainMonitor this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       ChainMonitor_free(this_obj_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKMonitorUpdateId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
-       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKMonitorUpdateId o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = MonitorUpdateId_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKMonitorUpdateId a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKMonitorUpdateId b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Persist_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKLockedChannelMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockedChannelMonitor_free(this_obj_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKChainMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ChainMonitor_free(this_obj_conv);
+}
+
+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) {
+       void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
+       CHECK_ACCESS(chain_source_ptr);
+       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
        // 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
@@ -16990,30 +18738,39 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e
                        LDKFilter_JCalls_cloned(&chain_source_conv.some);
                }
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
+       void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
+       CHECK_ACCESS(feeest_ptr);
+       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
        if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&feeest_conv);
        }
-       LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
        if (persister_conv.free == LDKPersist_JCalls_free) {
                // 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, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17041,11 +18798,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1cla
        }
        (*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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = ret_var.data[j];
                uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
                ret_arr_ptr[j] = ret_conv_9_ref;
        }
@@ -17072,13 +18830,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1mo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t k = 0; k < ret_var.datalen; k++) {
                LDKOutPoint ret_conv_10_var = ret_var.data[k];
+               uint64_t ret_conv_10_ref = 0;
                CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
+               ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
                if (ret_conv_10_var.is_owned) {
                        ret_conv_10_ref |= 1;
                }
@@ -17089,11 +18849,28 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1mo
        return ret_arr;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
+       LDKChainMonitor this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorUpdateId completed_update_id_conv;
+       completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
+       completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
+       completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
+       LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+       *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
+       return (uint64_t)ret_conv;
+}
+
 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_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17102,7 +18879,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(J
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17111,7 +18888,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNI
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
+       LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
        *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17120,7 +18897,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsPro
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17152,9 +18929,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17189,14 +18967,46 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEn
        MonitorUpdateError_free(this_obj_conv);
 }
 
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr val_conv = java_to_owned_str(env, val);
+       MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new(JNIEnv *env, jclass clz, jstring a_arg) {
+       LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
+       LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKMonitorUpdateError orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17205,7 +19015,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(J
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MonitorEvent_free(this_ptr_conv);
 }
@@ -17240,6 +19052,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1t
        return ret_ref;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+       *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(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_update_failed(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
+       LDKCVec_u8Z ret_var = MonitorEvent_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_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKHTLCUpdate this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -17252,9 +19095,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17284,7 +19128,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *en
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Balance_free(this_ptr_conv);
 }
@@ -17344,9 +19190,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17371,9 +19218,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1mon
        LDKChannelMonitorUpdate updates_conv;
        updates_conv.inner = (void*)(updates & (~1));
        updates_conv.is_owned = false;
-       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
+       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
+       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
        *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
        return (uint64_t)ret_conv;
@@ -17401,7 +19254,8 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1o
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
@@ -17417,7 +19271,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
+       void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
+       if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
+       LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
        ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
 }
 
@@ -17426,11 +19282,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1a
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
@@ -17444,11 +19301,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1a
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
+               *ret_conv_7_copy = ret_var.data[h];
                uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
                ret_arr_ptr[h] = ret_conv_7_ref;
        }
@@ -17461,9 +19319,12 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1l
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < ret_var.datalen; i++) {
                LDKTransaction ret_conv_8_var = ret_var.data[i];
@@ -17472,6 +19333,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1l
                Transaction_free(ret_conv_8_var);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -17493,28 +19355,37 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
        (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17534,17 +19405,23 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconn
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -17569,28 +19446,37 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transa
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
        (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17610,17 +19496,23 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transaction_1u
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
        unsigned char (*txid_ref)[32] = &txid_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -17636,23 +19528,30 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1best_1
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17669,13 +19568,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1r
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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;
 }
@@ -17685,9 +19586,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1be
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17699,11 +19601,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1c
        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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = ret_var.data[j];
                uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
                ret_arr_ptr[j] = ret_conv_9_ref;
        }
@@ -17716,7 +19619,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMo
        LDKu8slice ser_ref;
        ser_ref.datalen = (*env)->GetArrayLength(env, ser);
        ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
-       LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
+       void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
+       if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
+       LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
        (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
@@ -17769,9 +19674,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
        (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
        LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17783,9 +19689,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17853,9 +19760,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17911,7 +19819,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor
        LDKDelayedPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -17977,7 +19887,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        LDKPublicKey per_commitment_point_arg_ref;
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
        LDKPublicKey revocation_pubkey_arg_ref;
        CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
@@ -17986,9 +19898,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
        (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18000,9 +19913,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18042,9 +19956,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18066,7 +19981,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_
        LDKStaticPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -18110,15 +20027,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        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);
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18130,9 +20050,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18162,7 +20083,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SpendableOutputDescriptor_free(this_ptr_conv);
 }
@@ -18180,7 +20103,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1
        outpoint_conv.inner = (void*)(outpoint & (~1));
        outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
        outpoint_conv = OutPoint_clone(&outpoint_conv);
-       LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
+       void* output_ptr = (void*)(((uint64_t)output) & ~1);
+       CHECK_ACCESS(output_ptr);
+       LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
        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);
@@ -18231,28 +20156,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BaseSign_free(this_ptr_conv);
 }
 
 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSign* orig_conv = (LDKSign*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Sign_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        KeysInterface_free(this_ptr_conv);
 }
@@ -18383,9 +20316,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18415,9 +20349,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
        (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
        LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18429,9 +20364,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterpart
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18467,9 +20403,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1ou
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18481,9 +20418,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channe
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18528,7 +20466,7 @@ 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_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+       LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
        *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -18537,7 +20475,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JN
        LDKInMemorySigner this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -18576,9 +20514,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *en
        (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
        unsigned char (*seed_ref)[32] = &seed_arr;
        LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18594,9 +20533,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channe
        (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
        unsigned char (*params_ref)[32] = &params_arr;
        LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18616,7 +20556,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendab
        int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
        for (size_t b = 0; b < descriptors_constr.datalen; b++) {
                int64_t descriptors_conv_27 = descriptors_vals[b];
-               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
+               void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
+               CHECK_ACCESS(descriptors_conv_27_ptr);
+               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
                descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
                descriptors_constr.data[b] = descriptors_conv_27_conv;
        }
@@ -18630,7 +20572,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendab
        int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
        for (size_t h = 0; h < outputs_constr.datalen; h++) {
                int64_t outputs_conv_7 = outputs_vals[h];
-               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
+               void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
+               CHECK_ACCESS(outputs_conv_7_ptr);
+               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
                outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
                outputs_constr.data[h] = outputs_conv_7_conv;
        }
@@ -18648,72 +20592,11 @@ 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_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+       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_PaymentId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKPaymentId this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       PaymentId_free(this_obj_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1hash(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = false;
-       int64_t ret_val = PaymentId_hash(&o_conv);
-       return ret_val;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKPaymentId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKPaymentId ret_var = PaymentId_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 jboolean JNICALL Java_org_ldk_impl_bindings_PaymentId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
-       LDKPaymentId a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = false;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = false;
-       jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
-       return ret_val;
-}
-
-JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentId_1write(JNIEnv *env, jclass clz, int64_t obj) {
-       LDKPaymentId obj_conv;
-       obj_conv.inner = (void*)(obj & (~1));
-       obj_conv.is_owned = false;
-       LDKCVec_u8Z ret_var = PaymentId_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_PaymentId_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = PaymentId_read(ser_ref);
-       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
-       return (uint64_t)ret_conv;
-}
-
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKChannelManager this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -18749,9 +20632,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18776,9 +20660,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv
        best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
        best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
        LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18790,9 +20675,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18853,9 +20739,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1se
 
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18867,9 +20754,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18907,9 +20795,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1f
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18947,11 +20836,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1f
        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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -18980,9 +20872,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JN
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18994,9 +20887,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19034,9 +20928,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counte
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19059,11 +20954,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1fundin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -19093,7 +20991,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
 }
@@ -19127,7 +21027,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendab
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
 }
@@ -19191,7 +21093,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmat
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
 }
@@ -19210,7 +21114,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1cl
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
        val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
 }
@@ -19287,17 +21193,26 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv
        funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
        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);
+       void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
+       CHECK_ACCESS(short_channel_id_arg_ptr);
+       LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
        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);
+       void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
+       CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
+       LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
+       void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
+       CHECK_ACCESS(confirmations_required_arg_ptr);
+       LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
        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);
+       void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
+       CHECK_ACCESS(force_close_spend_delay_arg_ptr);
+       LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
        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_channel_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19309,9 +21224,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19320,7 +21236,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentSendFailure_free(this_ptr_conv);
 }
@@ -19334,7 +21252,9 @@ 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);
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
        a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
        *ret_copy = PaymentSendFailure_parameter_error(a_conv);
@@ -19352,7 +21272,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1p
        int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
        for (size_t w = 0; w < a_constr.datalen; w++) {
                int64_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
+               void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
+               CHECK_ACCESS(a_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
                a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
                a_constr.data[w] = a_conv_22_conv;
        }
@@ -19373,7 +21295,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1fa
        int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
        for (size_t k = 0; k < a_constr.datalen; k++) {
                int64_t a_conv_10 = a_vals[k];
-               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
+               void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
+               CHECK_ACCESS(a_conv_10_ptr);
+               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
                a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
                a_constr.data[k] = a_conv_10_conv;
        }
@@ -19384,49 +21308,67 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1fa
        return ret_ref;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
-       LDKCVec_CResult_NoneAPIErrorZZ a_constr;
-       a_constr.datalen = (*env)->GetArrayLength(env, a);
-       if (a_constr.datalen > 0)
-               a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
+       LDKCVec_CResult_NoneAPIErrorZZ results_constr;
+       results_constr.datalen = (*env)->GetArrayLength(env, results);
+       if (results_constr.datalen > 0)
+               results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
        else
-               a_constr.data = NULL;
-       int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
-       for (size_t w = 0; w < a_constr.datalen; w++) {
-               int64_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
-               a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
-               a_constr.data[w] = a_conv_22_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
+               results_constr.data = NULL;
+       int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
+       for (size_t w = 0; w < results_constr.datalen; w++) {
+               int64_t results_conv_22 = results_vals[w];
+               void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
+               CHECK_ACCESS(results_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
+               results_constr.data[w] = results_conv_22_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
+       LDKRouteParameters failed_paths_retry_conv;
+       failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
+       failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
+       failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
-       *ret_copy = PaymentSendFailure_partial_failure(a_constr);
+       *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t params) {
-       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
+       void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
+       CHECK_ACCESS(fee_est_ptr);
+       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
        if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
        }
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
        if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&chain_monitor_conv);
        }
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
        if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
@@ -19440,9 +21382,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv
        params_conv.is_owned = (params & 1) || (params == 0);
        params_conv = ChainParameters_clone(&params_conv);
        LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19454,9 +21397,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1curren
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19484,13 +21428,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -19506,13 +21452,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -19587,19 +21535,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payme
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int64_t payment_id) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRoute route_conv;
        route_conv.inner = (void*)(route & (~1));
        route_conv.is_owned = false;
-       LDKPaymentId payment_id_conv;
-       payment_id_conv.inner = (void*)(payment_id & (~1));
-       payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
-       payment_id_conv = PaymentId_clone(&payment_id_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
-       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
+       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
        return (uint64_t)ret_conv;
 }
 
@@ -19655,7 +21602,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1nod
        int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
        for (size_t m = 0; m < addresses_constr.datalen; m++) {
                int64_t addresses_conv_12 = addresses_vals[m];
-               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
+               void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
+               CHECK_ACCESS(addresses_conv_12_ptr);
+               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
                addresses_constr.data[m] = addresses_conv_12_conv;
        }
        (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
@@ -19708,21 +21657,13 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1ou
        return ret_arr;
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
-       LDKChannelManager this_arg_conv;
-       this_arg_conv.inner = (void*)(this_arg & (~1));
-       this_arg_conv.is_owned = false;
-       LDKOutPoint funding_txo_conv;
-       funding_txo_conv.inner = (void*)(funding_txo & (~1));
-       funding_txo_conv.is_owned = false;
-       ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
-}
-
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
        LDKChannelManager this_arg_conv;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
        LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
        *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
@@ -19736,7 +21677,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        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);
@@ -19747,7 +21690,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19756,7 +21699,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsP
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19765,7 +21708,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19774,7 +21717,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19799,9 +21742,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1be
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19812,7 +21756,7 @@ 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_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19839,7 +21783,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19847,7 +21792,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1k
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
        if (val_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&val_conv);
@@ -19859,7 +21806,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19867,7 +21815,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1f
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
        if (val_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&val_conv);
@@ -19879,7 +21829,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19887,7 +21838,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1c
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKWatch val_conv = *(LDKWatch*)(val_ptr);
        if (val_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&val_conv);
@@ -19899,7 +21852,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19907,7 +21861,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1t
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
        if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&val_conv);
@@ -19919,7 +21875,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19927,7 +21884,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1l
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKLogger val_conv = *(LDKLogger*)(val_ptr);
        if (val_conv.free == LDKLogger_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKLogger_JCalls_cloned(&val_conv);
@@ -19940,9 +21899,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19961,27 +21921,37 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1d
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
        if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&chain_monitor_conv);
        }
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
        if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -20006,9 +21976,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new
        }
        (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
        LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20041,9 +22012,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20062,9 +22034,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20088,9 +22061,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jcla
        features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
        features_arg_conv = InitFeatures_clone(&features_arg_conv);
        LDKInit ret_var = Init_new(features_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20102,9 +22076,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInit ret_var = Init_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20161,9 +22136,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *e
        (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
        LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
        LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20175,9 +22151,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20223,9 +22200,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *en
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
        LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20237,9 +22215,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPing ret_var = Ping_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20270,9 +22249,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *en
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
        LDKPong ret_var = Pong_new(byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20284,9 +22264,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPong ret_var = Pong_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20607,9 +22588,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20866,9 +22848,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20965,9 +22948,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
        LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20979,9 +22963,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21041,9 +23026,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *
        CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
        LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21055,9 +23041,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21117,9 +23104,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *
        CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
        LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21131,9 +23119,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21196,9 +23185,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env,
        scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
        LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21210,9 +23200,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdown ret_var = Shutdown_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21258,9 +23249,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1ma
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21272,9 +23264,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21346,11 +23339,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1ra
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -21378,9 +23374,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *
        fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
        fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
        LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21392,9 +23389,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21496,9 +23494,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21573,9 +23572,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIE
        CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
        (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21587,9 +23587,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21642,9 +23643,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21712,9 +23714,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1cl
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21807,9 +23810,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEn
                htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
        }
        LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21821,9 +23825,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21905,9 +23910,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv *e
        CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
        LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21919,9 +23925,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21974,9 +23981,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
        (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
        LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21988,9 +23996,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *en
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22050,9 +24059,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
        LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22064,9 +24074,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22134,9 +24145,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(J
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22233,9 +24245,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new
        CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22247,9 +24260,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22258,7 +24272,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetAddress_free(this_ptr_conv);
 }
@@ -22320,16 +24336,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEn
        return ret_arr;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = Result_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_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
        LDKu8slice ser_ref;
        ser_ref.datalen = (*env)->GetArrayLength(env, ser);
@@ -22352,9 +24358,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1g
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22457,7 +24464,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_
        int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                int64_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -22470,9 +24479,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22510,9 +24520,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1cont
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22539,9 +24550,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEn
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
        LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22553,9 +24565,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22574,9 +24587,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22709,9 +24723,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22806,9 +24821,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1c
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22844,9 +24860,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JN
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22858,9 +24875,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23003,9 +25021,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23043,9 +25062,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1content
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23072,9 +25092,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
        LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23086,9 +25107,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23156,9 +25178,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIE
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23170,9 +25193,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23286,9 +25310,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIE
        }
        (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
        LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23300,9 +25325,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23371,9 +25397,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(J
        }
        (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23385,9 +25412,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23440,9 +25468,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1ne
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23454,9 +25483,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1cl
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23524,9 +25554,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23538,9 +25569,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23549,7 +25581,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clon
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ErrorAction_free(this_ptr_conv);
 }
@@ -23638,19 +25672,24 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JN
        LDKLightningError this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
        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);
+       void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
+       CHECK_ACCESS(action_arg_ptr);
+       LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
        action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
        LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23662,9 +25701,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKLightningError ret_var = LightningError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23683,13 +25723,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_15_ref = 0;
                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;
+               ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
                if (ret_conv_15_var.is_owned) {
                        ret_conv_15_ref |= 1;
                }
@@ -23728,13 +25770,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_19_ref = 0;
                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;
+               ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
                if (ret_conv_19_var.is_owned) {
                        ret_conv_19_ref |= 1;
                }
@@ -23773,13 +25817,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -23818,13 +25864,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_25_ref = 0;
                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;
+               ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
                if (ret_conv_25_var.is_owned) {
                        ret_conv_25_ref |= 1;
                }
@@ -23863,11 +25911,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1upda
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -23888,9 +25939,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1comm
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23982,9 +26034,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEn
        commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
        commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
        LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23996,9 +26049,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24007,14 +26061,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ChannelMessageHandler_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        RoutingMessageHandler_free(this_ptr_conv);
 }
@@ -24701,7 +26759,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        CustomMessageHandler_free(this_ptr_conv);
 }
@@ -24715,9 +26775,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(J
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
        LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24728,7 +26789,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24737,7 +26798,7 @@ 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;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24746,7 +26807,7 @@ 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;
-       LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
+       LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24755,7 +26816,7 @@ 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;
-       LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
+       LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24769,9 +26830,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(J
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
        LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24782,7 +26844,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24791,7 +26853,7 @@ 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;
-       LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24807,7 +26869,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -24815,7 +26878,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1han
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
        if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelMessageHandler_JCalls_cloned(&val_conv);
@@ -24827,7 +26892,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -24835,7 +26901,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1ha
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
        if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
@@ -24844,20 +26912,25 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1ha
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv *env, jclass clz, int64_t chan_handler_arg, int64_t route_handler_arg) {
-       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
+       void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
+       CHECK_ACCESS(chan_handler_arg_ptr);
+       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
        if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
        }
-       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
+       void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
+       CHECK_ACCESS(route_handler_arg_ptr);
+       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
        if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
        }
        LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24865,15 +26938,19 @@ 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_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SocketDescriptor_free(this_ptr_conv);
 }
@@ -24902,9 +26979,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1conn
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
        LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24916,9 +26994,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24944,20 +27023,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *en
        CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
        (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
        unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
+       void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
+       CHECK_ACCESS(custom_message_handler_ptr);
+       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24969,13 +27053,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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, 33);
                (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -24987,7 +27073,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_
        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);
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
@@ -25001,7 +27089,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
@@ -25015,7 +27105,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -25025,7 +27117,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JN
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
+       void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
+       if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
+       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = (*env)->GetArrayLength(env, data);
        data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
@@ -25046,7 +27140,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnec
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
 }
 
@@ -25060,6 +27156,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1n
        PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKPeerManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       PeerManager_disconnect_all_peers(&this_arg_conv);
+}
+
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -25267,9 +27370,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
        (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
        LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25281,9 +27385,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25430,9 +27535,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIE
        CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
        (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25444,9 +27550,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25609,7 +27716,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1t
        LDKHTLCOutputInCommitment this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
 }
@@ -25618,12 +27727,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new
        LDKThirtyTwoBytes payment_hash_arg_ref;
        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);
+       void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
+       CHECK_ACCESS(transaction_output_index_arg_ptr);
+       LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25635,9 +27747,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25726,9 +27839,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25781,11 +27895,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -25806,11 +27923,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -25840,9 +27960,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
        funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25854,9 +27975,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25875,9 +27997,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25916,9 +28039,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
        pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25930,9 +28054,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25952,9 +28077,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25966,9 +28092,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26029,9 +28156,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26043,9 +28171,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26073,9 +28202,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26133,9 +28263,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26191,9 +28322,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction
        CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
        (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26259,9 +28391,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_
        CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
        (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26273,9 +28406,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26340,6 +28474,29 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEn
        ClosingTransaction_free(this_obj_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKClosingTransaction orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKClosingTransaction o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = ClosingTransaction_hash(&o_conv);
+       return ret_val;
+}
+
 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);
@@ -26354,9 +28511,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNI
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26368,9 +28526,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(J
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26486,9 +28645,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26553,9 +28713,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trus
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26601,9 +28762,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransactio
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26615,9 +28777,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransactio
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26700,9 +28863,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26714,9 +28878,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26728,9 +28893,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26742,9 +28908,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26781,9 +28948,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKInitFeatures ret_var = InitFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26792,9 +28960,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
        LDKInitFeatures ret_var = InitFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26811,9 +28980,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1un
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKNodeFeatures ret_var = NodeFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26822,9 +28992,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
        LDKNodeFeatures ret_var = NodeFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26841,9 +29012,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1un
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKChannelFeatures ret_var = ChannelFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26852,9 +29024,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIE
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
        LDKChannelFeatures ret_var = ChannelFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26871,9 +29044,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26882,9 +29056,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIE
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27019,9 +29194,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27062,9 +29238,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(
        script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
        LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       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_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKInvalidShutdownScript orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27098,9 +29290,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh
        (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
        unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27113,9 +29306,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(
        (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
        unsigned char (*script_hash_ref)[32] = &script_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27166,32 +29360,77 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compat
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
        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");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKType* orig_conv = (LDKType*)orig_ptr;
+       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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Type_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Score_free(this_ptr_conv);
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKLockableScore this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockableScore_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
+       void* score_ptr = (void*)(((uint64_t)score) & ~1);
+       CHECK_ACCESS(score_ptr);
+       LDKScore score_conv = *(LDKScore*)(score_ptr);
+       if (score_conv.free == LDKScore_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKScore_JCalls_cloned(&score_conv);
+       }
+       LDKLockableScore ret_var = LockableScore_new(score_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_LockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKLockableScore obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = LockableScore_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_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKNodeId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -27204,9 +29443,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeId ret_var = NodeId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27218,9 +29458,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv
        CHECK((*env)->GetArrayLength(env, pubkey) == 33);
        (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
        LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27278,9 +29519,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27296,7 +29538,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetworkUpdate_free(this_ptr_conv);
 }
@@ -27350,7 +29594,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Eve
        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");
+       LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27362,37 +29606,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEn
        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;
-       if (ret_var.is_owned) {
-               ret_ref |= 1;
-       }
-       return ret_ref;
-}
-
-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);
-       val_conv = NetworkGraph_clone(&val_conv);
-       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);
-       network_graph_conv = NetworkGraph_clone(&network_graph_conv);
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       network_graph_conv.is_owned = false;
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -27401,15 +29621,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNI
                        LDKAccess_JCalls_cloned(&chain_access_conv.some);
                }
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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(network_graph_conv, chain_access_conv, logger_conv);
+       LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27420,7 +29643,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -27436,7 +29661,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Rou
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27445,7 +29670,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Mes
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27531,7 +29756,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1h
        LDKDirectionalChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -27541,9 +29768,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27566,11 +29794,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27587,7 +29818,9 @@ 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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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));
@@ -27598,9 +29831,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new
        last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
        last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27612,9 +29846,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27654,9 +29889,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27679,9 +29915,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27704,11 +29941,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27729,9 +29969,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27754,11 +29995,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27788,7 +30032,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sa
        LDKChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
 }
@@ -27798,11 +30044,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcem
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27839,16 +30088,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *en
        two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
        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);
+       void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
+       CHECK_ACCESS(capacity_sats_arg_ptr);
+       LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
        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);
        announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
        LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27860,9 +30112,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27929,9 +30182,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv *env, jclass clz, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
        LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27954,9 +30208,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28004,9 +30259,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28090,7 +30346,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1add
        int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                int64_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -28103,11 +30361,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28143,7 +30404,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(J
        int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
        for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
                int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
-               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               CHECK_ACCESS(addresses_arg_conv_12_ptr);
+               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
                addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
        }
        (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
@@ -28152,9 +30415,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(J
        announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
        announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28166,9 +30430,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28227,11 +30492,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbo
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28252,11 +30520,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28294,9 +30565,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env,
        announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
        announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
        LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28308,9 +30580,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28364,9 +30637,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *e
        CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
        (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
        LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28378,9 +30652,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JN
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28418,7 +30693,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -28439,7 +30716,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -28538,9 +30817,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1featur
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28578,9 +30858,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1fea
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28641,9 +30922,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv *env,
        channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
        channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
        LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28655,9 +30937,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28716,17 +30999,20 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIE
        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);
+       jobjectArray ret_arr = NULL;
+       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_tArray ret_conv_12_arr = NULL;
+               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];
+                       uint64_t ret_conv_12_conv_10_ref = 0;
                        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;
+                       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;
                        }
@@ -28736,6 +31022,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIE
                FREE(ret_conv_12_var.data);
                (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -28773,7 +31060,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env,
        Route_set_paths(&this_ptr_conv, val_constr);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(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;
+       LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               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_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       Route_set_payee(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
        LDKCVec_CVec_RouteHopZZ paths_arg_constr;
        paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
        if (paths_arg_constr.datalen > 0)
@@ -28800,10 +31115,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jcl
                (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
                paths_arg_constr.data[m] = paths_arg_conv_12_constr;
        }
-       LDKRoute ret_var = Route_new(paths_arg_constr);
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28815,9 +31135,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, j
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoute ret_var = Route_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28880,6 +31201,367 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jc
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKRouteParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteParameters_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       RouteParameters_set_payee(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_value_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKRouteParameters orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteParameters_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_RouteParameters_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = RouteParameters_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKPayee this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Payee_free(this_obj_conv);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPublicKey val_ref;
+       CHECK((*env)->GetArrayLength(env, val) == 33);
+       (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
+       Payee_set_pubkey(&this_ptr_conv, val_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               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_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKInvoiceFeatures val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = InvoiceFeatures_clone(&val_conv);
+       Payee_set_features(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
+       int64_tArray ret_arr = NULL;
+       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++) {
+               LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
+               CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               if (ret_conv_11_var.is_owned) {
+                       ret_conv_11_ref |= 1;
+               }
+               ret_arr_ptr[l] = ret_conv_11_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_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintZ val_constr;
+       val_constr.datalen = (*env)->GetArrayLength(env, val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               val_constr.data = NULL;
+       int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
+       for (size_t l = 0; l < val_constr.datalen; l++) {
+               int64_t val_conv_11 = val_vals[l];
+               LDKRouteHint val_conv_11_conv;
+               val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
+               val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
+               val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
+               val_constr.data[l] = val_conv_11_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
+       Payee_set_route_hints(&this_ptr_conv, val_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
+       val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
+       Payee_set_expiry_time(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
+       LDKPublicKey pubkey_arg_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
+       LDKInvoiceFeatures 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 = InvoiceFeatures_clone(&features_arg_conv);
+       LDKCVec_RouteHintZ route_hints_arg_constr;
+       route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
+       if (route_hints_arg_constr.datalen > 0)
+               route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               route_hints_arg_constr.data = NULL;
+       int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
+       for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
+               int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
+               LDKRouteHint route_hints_arg_conv_11_conv;
+               route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
+               route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
+               route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
+               route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
+       void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
+       CHECK_ACCESS(expiry_time_arg_ptr);
+       LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
+       expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
+       LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKPayee orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKPayee ret_var = Payee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = Payee_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKPayee a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKPayee b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = Payee_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKPayee obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Payee_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_Payee_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = Payee_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_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
+       LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
+       LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKRouteHint this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -28887,14 +31569,90 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, j
        RouteHint_free(this_obj_conv);
 }
 
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+       for (size_t o = 0; o < ret_var.datalen; o++) {
+               LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
+               CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               if (ret_conv_14_var.is_owned) {
+                       ret_conv_14_ref |= 1;
+               }
+               ret_arr_ptr[o] = ret_conv_14_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_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ val_constr;
+       val_constr.datalen = (*env)->GetArrayLength(env, val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               val_constr.data = NULL;
+       int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
+       for (size_t o = 0; o < val_constr.datalen; o++) {
+               int64_t val_conv_14 = val_vals[o];
+               LDKRouteHintHop val_conv_14_conv;
+               val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
+               val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
+               val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
+               val_constr.data[o] = val_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
+       RouteHint_set_a(&this_ptr_conv, val_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
+       LDKCVec_RouteHintHopZ a_arg_constr;
+       a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
+       if (a_arg_constr.datalen > 0)
+               a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               a_arg_constr.data = NULL;
+       int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
+       for (size_t o = 0; o < a_arg_constr.datalen; o++) {
+               int64_t a_arg_conv_14 = a_arg_vals[o];
+               LDKRouteHintHop a_arg_conv_14_conv;
+               a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
+               a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
+               a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
+               a_arg_constr.data[o] = a_arg_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
+       LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKRouteHint orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28920,6 +31678,27 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env,
        return ret_val;
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteHint obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHint_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_RouteHint_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = RouteHint_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
 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));
@@ -28966,9 +31745,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNI
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29015,7 +31795,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minim
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
 }
@@ -29034,7 +31816,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maxim
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -29047,14 +31831,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e
        fees_arg_conv.inner = (void*)(fees_arg & (~1));
        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);
+       void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
        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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29066,9 +31855,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29094,77 +31884,37 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *e
        return ret_val;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, 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, int64_t scorer) {
-       LDKPublicKey our_node_pubkey_ref;
-       CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
-       (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
-       LDKNetworkGraph network_conv;
-       network_conv.inner = (void*)(network & (~1));
-       network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK((*env)->GetArrayLength(env, payee) == 33);
-       (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
-       LDKCVec_ChannelDetailsZ first_hops_constr;
-       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
-       if (first_hops != NULL) {
-               first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
-               if (first_hops_constr.datalen > 0)
-                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-               else
-                       first_hops_constr.data = NULL;
-               int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
-               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
-                       int64_t first_hops_conv_16 = first_hops_vals[q];
-                       LDKChannelDetails first_hops_conv_16_conv;
-                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
-                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
-                       first_hops_constr.data[q] = first_hops_conv_16_conv;
-               }
-               (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
-               first_hops_ptr = &first_hops_constr;
-       }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               int64_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
-       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);
-       }
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
-       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
-       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteHintHop obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHintHop_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_RouteHintHop_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = RouteHintHop_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_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger, int64_t scorer) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
        LDKPublicKey our_node_pubkey_ref;
        CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
        (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
        LDKNetworkGraph network_conv;
        network_conv.inner = (void*)(network & (~1));
        network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK((*env)->GetArrayLength(env, payee) == 33);
-       (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
-       LDKInvoiceFeatures payee_features_conv;
-       payee_features_conv.inner = (void*)(payee_features & (~1));
-       payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
-       payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
        LDKCVec_ChannelDetailsZ first_hops_constr;
        LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
        if (first_hops != NULL) {
@@ -29184,30 +31934,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jcl
                (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
                first_hops_ptr = &first_hops_constr;
        }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               int64_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
+       *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
        if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
        return (uint64_t)ret_conv;
 }
@@ -29219,11 +31957,101 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jcla
        Scorer_free(this_obj_conv);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat) {
-       LDKScorer ret_var = Scorer_new(base_penalty_msat);
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKScoringParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ScoringParameters_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
+       LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKScoringParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = ScoringParameters_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_ScoringParameters_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = ScoringParameters_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_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
+       LDKScoringParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = (params & 1) || (params == 0);
+       // Warning: we need a move here but no clone is available for LDKScoringParameters
+       LDKScorer ret_var = Scorer_new(params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29232,9 +32060,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jc
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
        LDKScorer ret_var = Scorer_default();
+       uint64_t ret_ref = 0;
+       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.
+       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_ScoringParameters_1default(JNIEnv *env, jclass clz) {
+       LDKScoringParameters ret_var = ScoringParameters_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29245,11 +32086,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *e
        LDKScorer this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
+       LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
        *ret_ret = Scorer_as_Score(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKScorer obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Scorer_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_Scorer_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = Scorer_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKFilesystemPersister this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -29260,9 +32122,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIE
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
        LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
        LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29293,7 +32156,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1
        LDKFilesystemPersister this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
@@ -29307,7 +32172,7 @@ 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_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
+       LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
        *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -29321,18 +32186,24 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        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 net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
-       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
        if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
        }
-       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
        if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKEventHandler_JCalls_cloned(&event_handler_conv);
@@ -29349,15 +32220,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(
        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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29411,9 +32285,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoice ret_var = Invoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29443,9 +32318,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29464,9 +32340,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEn
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29500,9 +32377,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29521,9 +32399,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29557,9 +32436,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29589,9 +32469,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29693,9 +32574,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSha256 ret_var = Sha256_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29733,9 +32615,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDescription ret_var = Description_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29768,14 +32651,49 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env,
        PayeePubKey_free(this_obj_conv);
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayeePubKey this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
+       LDKPayeePubKey this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPublicKey val_ref;
+       CHECK((*env)->GetArrayLength(env, val) == 33);
+       (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
+       PayeePubKey_set_a(&this_ptr_conv, val_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
+       LDKPublicKey a_arg_ref;
+       CHECK((*env)->GetArrayLength(env, a_arg) == 33);
+       (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
+       LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKPayeePubKey orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29813,9 +32731,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29848,14 +32767,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEn
        MinFinalCltvExpiry_free(this_obj_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
+       LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29883,7 +32830,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Fallback_free(this_ptr_conv);
 }
@@ -29953,9 +32902,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29985,9 +32935,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30028,9 +32979,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30051,9 +33003,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30091,11 +33044,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(J
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_payment_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30105,11 +33061,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNI
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDescription ret_var = RawInvoice_description(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30119,11 +33078,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30133,11 +33095,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1ha
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_description_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30147,11 +33112,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JN
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKExpiryTime ret_var = RawInvoice_expiry_time(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30161,11 +33129,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1clt
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30184,11 +33155,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = RawInvoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30198,13 +33172,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1r
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
@@ -30267,9 +33243,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = Invoice_clone(&this_arg_conv);
        LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30326,7 +33303,7 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secre
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
-       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
        return ret_arr;
 }
 
@@ -30335,11 +33312,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *e
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = Invoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30361,6 +33341,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEn
        return ret_val;
 }
 
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKInvoice this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       jboolean ret_val = Invoice_is_expired(&this_arg_conv);
+       return ret_val;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -30374,13 +33362,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1rout
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
@@ -30396,13 +33386,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
                CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
                if (ret_conv_11_var.is_owned) {
                        ret_conv_11_ref |= 1;
                }
@@ -30421,12 +33413,12 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *en
        return ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
+       *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -30493,9 +33485,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(J
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = PrivateRoute_clone(&this_arg_conv);
        LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30616,7 +33609,9 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SignOrCreationError_free(this_ptr_conv);
 }
@@ -30659,17 +33654,252 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1st
        return ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKInvoicePayer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       InvoicePayer_free(this_obj_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Payer_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Router_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKRetryAttempts this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RetryAttempts_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RetryAttempts_set_a(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
+       LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKRetryAttempts orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKRetryAttempts a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKRetryAttempts b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRetryAttempts o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       PaymentError_free(this_ptr_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
+       LDKStr a_conv = java_to_owned_str(env, a);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_invoice(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
+       LDKLightningError a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = (a & 1) || (a == 0);
+       a_conv = LightningError_clone(&a_conv);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_routing(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
+       a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_sending(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
+       void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
+       CHECK_ACCESS(payer_ptr);
+       LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
+       if (payer_conv.free == LDKPayer_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKPayer_JCalls_cloned(&payer_conv);
+       }
+       void* router_ptr = (void*)(((uint64_t)router) & ~1);
+       CHECK_ACCESS(router_ptr);
+       LDKRouter router_conv = *(LDKRouter*)(router_ptr);
+       if (router_conv.free == LDKRouter_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKRouter_JCalls_cloned(&router_conv);
+       }
+       LDKLockableScore scorer_conv;
+       scorer_conv.inner = (void*)(scorer & (~1));
+       scorer_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       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);
+       }
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
+       if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKEventHandler_JCalls_cloned(&event_handler_conv);
+       }
+       LDKRetryAttempts retry_attempts_conv;
+       retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
+       retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
+       retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
+       LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       unsigned char payment_hash_arr[32];
+       CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
+       (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
+       unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
+       InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKInvoicePayer 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 = InvoicePayer_as_EventHandler(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description) {
        LDKChannelManager channelmanager_conv;
        channelmanager_conv.inner = (void*)(channelmanager & (~1));
        channelmanager_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
        }
        LDKCurrency network_conv = LDKCurrency_from_java(env, network);
-       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
+       void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
+       CHECK_ACCESS(amt_msat_ptr);
+       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
        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");
@@ -30677,6 +33907,53 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1chan
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKDefaultRouter this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       DefaultRouter_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
+       LDKNetworkGraph network_graph_conv;
+       network_graph_conv.inner = (void*)(network_graph & (~1));
+       network_graph_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       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);
+       }
+       LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKDefaultRouter this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(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;
+       LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
        LDKStr s_conv = java_to_owned_str(env, s);
        LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
index c67f2147dfdcf9c433119a5af39ee7381c86622c..3b19333747edec288430e7ca49ccb86aff6705c4 100644 (file)
@@ -9,7 +9,8 @@
 
 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
+#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
+#define CHECK_ACCESS(p)
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
 
@@ -794,18 +795,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysD
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -815,18 +818,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKe
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelPublicKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -836,9 +841,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysE
        LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -882,18 +888,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCom
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCOutputInCommitment res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -903,18 +911,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyCha
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -924,18 +934,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransact
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -945,18 +957,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmen
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHolderCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -966,18 +980,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitment
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -987,9 +1003,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingT
        LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedClosingTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       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) {
@@ -1004,18 +1021,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTrans
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1025,9 +1044,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitme
        LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1042,13 +1062,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1Sign
        LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_SignatureZ res_var = (*val->contents.result);
-       jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray res_arr = NULL;
+       res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < res_var.datalen; i++) {
                int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
                (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
                (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
        }
+       
        return res_arr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1063,18 +1085,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptD
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1084,18 +1108,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptI
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKInvalidShutdownScript err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1119,18 +1145,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeE
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRouteHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -1174,20 +1202,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErro
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+       ret->datalen = (*env)->GetArrayLength(env, elems);
+       if (ret->datalen == 0) {
+               ret->data = NULL;
+       } else {
+               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ 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];
+                       LDKRouteHint arr_elem_conv;
+                       arr_elem_conv.inner = (void*)(arr_elem & (~1));
+                       arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       ret->data[i] = arr_elem_conv;
+               }
+               (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
+       }
+       return (uint64_t)ret;
+}
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = RouteHint_clone(&orig->data[i]);
+       }
+       return ret;
+}
 static jclass LDKCOption_u64Z_Some_class = NULL;
 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
 static jclass LDKCOption_u64Z_None_class = NULL;
@@ -1216,57 +1296,126 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from
                default: abort();
        }
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
-       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKPayee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
        ret->datalen = (*env)->GetArrayLength(env, elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
+               ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ 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];
-                       LDKChannelDetails arr_elem_conv;
+                       LDKRouteHintHop arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
+                       arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
                (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
-       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
+       LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+               ret.data[i] = RouteHintHop_clone(&orig->data[i]);
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
-       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHintHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
+       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
        ret->datalen = (*env)->GetArrayLength(env, elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
+               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ 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];
-                       LDKRouteHint arr_elem_conv;
+                       LDKChannelDetails arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
                (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
-       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = RouteHint_clone(&orig->data[i]);
+               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
        }
        return ret;
 }
@@ -1277,18 +1426,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningE
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -1306,17 +1457,6 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessError
        jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
        return err_conv;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
-       LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
-       ret->a = a;
-       LDKTransaction b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       b_ref.data_is_owned = false;
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -1348,7 +1488,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTran
                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_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1388,6 +1530,10 @@ static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
+static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
+static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
+static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
+static jmethodID LDKMonitorEvent_UpdateFailed_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;"));
@@ -1399,24 +1545,52 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNI
        CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
        LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
        CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
+       LDKMonitorEvent_UpdateCompleted_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted;"));
+       CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
+       LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
+       CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
+       LDKMonitorEvent_UpdateFailed_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed;"));
+       CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
+       LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
+       CHECK(LDKMonitorEvent_UpdateFailed_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);
        switch(obj->tag) {
                case LDKMonitorEvent_HTLCEvent: {
                        LDKHTLCUpdate htlc_event_var = obj->htlc_event;
+                       uint64_t htlc_event_ref = 0;
                        CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
+                       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_CommitmentTxConfirmed: {
                        LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
+                       uint64_t commitment_tx_confirmed_ref = 0;
                        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;
+                       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);
                }
+               case LDKMonitorEvent_UpdateCompleted: {
+                       LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
+                       uint64_t funding_txo_ref = 0;
+                       CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
+               }
+               case LDKMonitorEvent_UpdateFailed: {
+                       LDKOutPoint update_failed_var = obj->update_failed;
+                       uint64_t update_failed_ref = 0;
+                       CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
+               }
                default: abort();
        }
 }
@@ -1430,7 +1604,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new
                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];
-                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
                        arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1504,9 +1680,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from
        switch(obj->tag) {
                case LDKNetworkUpdate_ChannelUpdateMessage: {
                        LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
                }
                case LDKNetworkUpdate_ChannelClosed: {
@@ -1577,24 +1754,27 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescripto
        switch(obj->tag) {
                case LDKSpendableOutputDescriptor_StaticOutput: {
                        LDKOutPoint outpoint_var = obj->static_output.outpoint;
+                       uint64_t outpoint_ref = 0;
                        CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
+                       outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
                        uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
                }
                case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
                        LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
+                       uint64_t delayed_payment_output_ref = 0;
                        CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
+                       delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
                }
                case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
                        LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
+                       uint64_t static_payment_output_ref = 0;
                        CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
+                       static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
                        return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
                }
                default: abort();
@@ -1610,7 +1790,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDes
                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];
-                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
                        arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1660,9 +1842,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1
        switch(obj->tag) {
                case LDKErrorAction_DisconnectPeer: {
                        LDKErrorMessage msg_var = obj->disconnect_peer.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;
+                       uint64_t msg_ref = 0;
+                       if ((uint64_t)msg_var.inner > 4096) {
+                               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.
+                               msg_ref = (uint64_t)msg_var.inner & ~1;
+                       }
                        return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
                }
                case LDKErrorAction_IgnoreError: {
@@ -1674,9 +1859,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1
                }
                case LDKErrorAction_SendErrorMessage: {
                        LDKErrorMessage msg_var = obj->send_error_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
                }
                default: abort();
@@ -1824,133 +2010,149 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
                        LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendOpenChannel: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
                        LDKOpenChannel msg_var = obj->send_open_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingCreated: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
                        LDKFundingCreated msg_var = obj->send_funding_created.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingSigned: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
                        LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendFundingLocked: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
                        LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendAnnouncementSignatures: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
                        LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_UpdateHTLCs: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
                        LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+                       uint64_t updates_ref = 0;
                        CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
+                       updates_ref = (uint64_t)updates_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
                }
                case LDKMessageSendEvent_SendRevokeAndACK: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
                        LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendClosingSigned: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
                        LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendShutdown: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
                        LDKShutdown msg_var = obj->send_shutdown.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendChannelReestablish: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
                        LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
                        LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+                       uint64_t update_msg_ref = 0;
                        CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+                       update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
                }
                case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
                        LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
                }
                case LDKMessageSendEvent_BroadcastChannelUpdate: {
                        LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
                }
                case LDKMessageSendEvent_SendChannelUpdate: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
                        LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_HandleError: {
@@ -1963,27 +2165,30 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f
                        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);
                        LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendShortIdsQuery: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
                        LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
                }
                case LDKMessageSendEvent_SendReplyChannelRange: {
                        int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
                        (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
                        LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
                }
                default: abort();
@@ -1999,7 +2204,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_
                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];
-                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
                        arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2021,18 +2228,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDec
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInitFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2042,18 +2251,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDec
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2063,18 +2274,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeatures
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2084,18 +2297,66 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeatures
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoiceFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScoringParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScorer res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2105,18 +2366,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentO
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2126,18 +2389,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOu
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -2153,9 +2418,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutput
        LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -2171,28 +2437,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1er
        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;
-       CHECK((*env)->GetArrayLength(env, a) == 64);
-       (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
-       ret->a = a_ref;
-       LDKCVec_SignatureZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
-       else
-               b_constr.data = NULL;
-       for (size_t i = 0; i < b_constr.datalen; i++) {
-               int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
-               LDKSignature b_conv_8_ref;
-               CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
-               (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
-               b_constr.data[i] = b_conv_8_ref;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -2209,13 +2453,15 @@ static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(
 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
        LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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, 64);
                (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -2344,10 +2590,11 @@ LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* th
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
+       uint64_t holder_tx_ref = 0;
        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;
+       holder_tx_ref = (uint64_t)holder_tx_var.inner;
        if (holder_tx_var.is_owned) {
                holder_tx_ref |= 1;
        }
@@ -2358,7 +2605,9 @@ LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* th
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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);
@@ -2399,10 +2648,11 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
@@ -2413,7 +2663,9 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2438,7 +2690,9 @@ LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const vo
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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);
@@ -2455,10 +2709,11 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htl
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
@@ -2469,7 +2724,9 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2498,7 +2755,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const vo
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2521,10 +2780,11 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
        int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
@@ -2535,7 +2795,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2558,10 +2820,11 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
        int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
@@ -2572,7 +2835,9 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2589,10 +2854,11 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void*
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKClosingTransaction closing_tx_var = *closing_tx;
-       // Warning: we may need a move here but no clone is available for LDKClosingTransaction
+       uint64_t closing_tx_ref = 0;
+       closing_tx_var = ClosingTransaction_clone(closing_tx);
        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;
+       closing_tx_ref = (uint64_t)closing_tx_var.inner;
        if (closing_tx_var.is_owned) {
                closing_tx_ref |= 1;
        }
@@ -2603,7 +2869,9 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2620,10 +2888,11 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKUnsignedChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UnsignedChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -2634,7 +2903,9 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
        }
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -2651,10 +2922,11 @@ void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransaction
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+       uint64_t channel_parameters_ref = 0;
        channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
        CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+       channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
        if (channel_parameters_var.is_owned) {
                channel_parameters_ref |= 1;
        }
@@ -2735,21 +3007,27 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *en
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
        return ret_arr;
 }
 
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction holder_tx_conv;
        holder_tx_conv.inner = (void*)(holder_tx & (~1));
        holder_tx_conv.is_owned = false;
@@ -2759,14 +3037,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
        return ret_arr;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -2776,7 +3058,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        unsigned char secret_arr[32];
        CHECK((*env)->GetArrayLength(env, secret) == 32);
        (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
@@ -2787,7 +3071,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counter
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -2797,7 +3083,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1com
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2813,7 +3101,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1re
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2832,7 +3122,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1re
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction htlc_tx_ref;
        htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
        htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
@@ -2850,7 +3142,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterpart
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKClosingTransaction closing_tx_conv;
        closing_tx_conv.inner = (void*)(closing_tx & (~1));
        closing_tx_conv.is_owned = false;
@@ -2860,7 +3154,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1tr
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -2870,7 +3166,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1an
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelTransactionParameters channel_parameters_conv;
        channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
        channel_parameters_conv.is_owned = false;
@@ -2883,11 +3181,14 @@ LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
        return this_arg->pubkeys;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2985,7 +3286,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIE
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
        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);
@@ -2999,7 +3302,7 @@ 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* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *res_ret = Sign_clone(&(*val->contents.result));
        return (uint64_t)res_ret;
 }
@@ -3007,9 +3310,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeError
        LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3041,7 +3345,8 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec
        LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
-       jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray res_arr = NULL;
+       res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < res_var.datalen; i++) {
                LDKCVec_u8Z res_conv_8_var = res_var.data[i];
@@ -3049,6 +3354,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec
                (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
                (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
        }
+       
        return res_arr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3063,18 +3369,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerD
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInMemorySigner res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -3087,7 +3395,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv
                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];
-                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
                        arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3118,19 +3428,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKChannelMonitor b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelMonitor_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3147,9 +3444,10 @@ static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LD
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
        LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3166,7 +3464,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHash
                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_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3188,7 +3488,8 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tu
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
-       int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
+       int64_tArray res_arr = NULL;
+       res_arr = (*env)->NewLongArray(env, res_var.datalen);
        int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
        for (size_t j = 0; j < res_var.datalen; j++) {
                LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
@@ -3205,27 +3506,6 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1B
        jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
        return err_conv;
 }
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKPaymentId 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 int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(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;
-}
 static jclass LDKCOption_u16Z_Some_class = NULL;
 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
 static jclass LDKCOption_u16Z_None_class = NULL;
@@ -3326,9 +3606,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr
                }
                case LDKAPIError_IncompatibleShutdownScript: {
                        LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+                       uint64_t script_ref = 0;
                        CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t script_ref = (uint64_t)script_var.inner & ~1;
+                       script_ref = (uint64_t)script_var.inner & ~1;
                        return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
                }
                default: abort();
@@ -3358,7 +3639,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIEr
                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];
-                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
                        arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3383,7 +3666,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNI
                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];
-                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
                        arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3441,7 +3726,7 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_ini
        LDKPaymentSendFailure_PartialFailure_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
        CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
-       LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
+       LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
        CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
 }
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
@@ -3453,7 +3738,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                }
                case LDKPaymentSendFailure_PathParameterError: {
                        LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
-                       int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
+                       int64_tArray path_parameter_error_arr = NULL;
+                       path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
                        int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
                        for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
                                LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
@@ -3466,7 +3752,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                }
                case LDKPaymentSendFailure_AllFailedRetrySafe: {
                        LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
-                       int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
+                       int64_tArray all_failed_retry_safe_arr = NULL;
+                       all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
                        int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
                        for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
                                uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
@@ -3476,17 +3763,27 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
                        return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
                }
                case LDKPaymentSendFailure_PartialFailure: {
-                       LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
-                       int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
-                       int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
-                       for (size_t w = 0; w < partial_failure_var.datalen; w++) {
-                               LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
-                               *partial_failure_conv_22_conv = partial_failure_var.data[w];
-                               *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
-                               partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
+                       LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+                       int64_tArray results_arr = NULL;
+                       results_arr = (*env)->NewLongArray(env, results_var.datalen);
+                       int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
+                       for (size_t w = 0; w < results_var.datalen; w++) {
+                               LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+                               *results_conv_22_conv = results_var.data[w];
+                               *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+                               results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
                        }
-                       (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
-                       return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
+                       (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
+                       LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+                       uint64_t failed_paths_retry_ref = 0;
+                       if ((uint64_t)failed_paths_retry_var.inner > 4096) {
+                               CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
+                       }
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
+                       return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
                }
                default: abort();
        }
@@ -3494,14 +3791,12 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKPaymentId 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;
+       int8_tArray res_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
+       return res_arr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
@@ -3523,19 +3818,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSend
        uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3546,19 +3828,14 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPay
        return ret_arr;
 }
 
-static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
-       return PaymentId_clone(&tuple->b);
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+       return ThirtyTwoBytes_clone(&tuple->b);
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
-       LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_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;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
+       return ret_arr;
 }
 
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -3644,7 +3921,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(J
                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];
-                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
                        arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3659,18 +3938,6 @@ static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddres
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
-       LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKThirtyTwoBytes b_ref;
-       CHECK((*env)->GetArrayLength(env, b) == 32);
-       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3769,16 +4036,18 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void*
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitor monitor_var = monitor;
+       uint64_t monitor_ref = 0;
        CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t monitor_ref = (uint64_t)monitor_var.inner;
+       monitor_ref = (uint64_t)monitor_var.inner;
        if (monitor_var.is_owned) {
                monitor_ref |= 1;
        }
@@ -3789,7 +4058,9 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -3806,16 +4077,18 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = update;
+       uint64_t update_ref = 0;
        CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
+       update_ref = (uint64_t)update_var.inner;
        if (update_var.is_owned) {
                update_ref |= 1;
        }
@@ -3826,7 +4099,9 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -3858,7 +4133,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void*
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t o = 0; o < ret_constr.datalen; o++) {
                int64_t ret_conv_14 = ret_vals[o];
-               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
+               void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
+               CHECK_ACCESS(ret_conv_14_ptr);
+               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
                ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
                ret_constr.data[o] = ret_conv_14_conv;
        }
@@ -3901,7 +4178,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env,
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -3916,7 +4195,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEn
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -3931,13 +4212,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIE
 }
 
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
@@ -4020,7 +4304,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1ne
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
-       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
        LDKTransaction tx_ref;
        tx_ref.datalen = (*env)->GetArrayLength(env, tx);
        tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
@@ -4148,7 +4434,9 @@ LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inb
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
        }
-       LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKSign ret_conv = *(LDKSign*)(ret_ptr);
        ret_conv = Sign_clone(&ret_conv);
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4198,7 +4486,9 @@ LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void*
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
        }
-       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4225,7 +4515,9 @@ LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const v
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
        }
-       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -4277,14 +4569,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEn
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
        return ret_arr;
 }
 
 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(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);
@@ -4293,11 +4589,14 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1des
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4305,21 +4604,27 @@ 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+       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) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
        (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
        return ret_arr;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKu8slice reader_ref;
        reader_ref.datalen = (*env)->GetArrayLength(env, reader);
        reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
@@ -4330,7 +4635,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z invoice_preimage_ref;
        invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
        invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
@@ -4412,7 +4719,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_arg, jclass confirmation_target) {
-       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
        LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
        int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
        return ret_val;
@@ -4489,19 +4798,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env,
        *res_ptr = LDKLogger_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
-       LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKChannelManager b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       // Warning: we need a move here but no clone is available for LDKChannelManager
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -4518,9 +4814,10 @@ static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(L
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
        LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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 & ~1;
+       ret_ref = (uint64_t)ret_var.inner & ~1;
        return ret_ref;
 }
 
@@ -4530,8 +4827,7 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1Block
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       *res_conv = (*val->contents.result);
+       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
        // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
        return ((uint64_t)res_conv) | 1;
 }
@@ -4539,9 +4835,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockH
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4551,18 +4848,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDe
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelConfig res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4572,18 +4871,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeE
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOutPoint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKType_JCalls {
@@ -4713,13 +5014,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, j
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -4727,7 +5032,9 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *en
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -4755,7 +5062,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1fro
        LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_TypeZ_Some: {
-                       LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
+                       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);
                }
@@ -4778,9 +5085,72 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZD
        LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+static jclass LDKPaymentError_Invoice_class = NULL;
+static jmethodID LDKPaymentError_Invoice_meth = NULL;
+static jclass LDKPaymentError_Routing_class = NULL;
+static jmethodID LDKPaymentError_Routing_meth = NULL;
+static jclass LDKPaymentError_Sending_class = NULL;
+static jmethodID LDKPaymentError_Sending_meth = NULL;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
+       LDKPaymentError_Invoice_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Invoice;"));
+       CHECK(LDKPaymentError_Invoice_class != NULL);
+       LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
+       CHECK(LDKPaymentError_Invoice_meth != NULL);
+       LDKPaymentError_Routing_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Routing;"));
+       CHECK(LDKPaymentError_Routing_class != NULL);
+       LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
+       CHECK(LDKPaymentError_Routing_meth != NULL);
+       LDKPaymentError_Sending_class =
+               (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Sending;"));
+       CHECK(LDKPaymentError_Sending_class != NULL);
+       LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
+       CHECK(LDKPaymentError_Sending_meth != NULL);
+}
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
+       LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+       switch(obj->tag) {
+               case LDKPaymentError_Invoice: {
+                       LDKStr invoice_str = obj->invoice;
+                       jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
+                       return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
+               }
+               case LDKPaymentError_Routing: {
+                       LDKLightningError routing_var = obj->routing;
+                       uint64_t routing_ref = 0;
+                       CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       routing_ref = (uint64_t)routing_var.inner & ~1;
+                       return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
+               }
+               case LDKPaymentError_Sending: {
+                       uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
+                       return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
+               }
+               default: abort();
+       }
+}
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       int8_tArray res_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
+       return res_arr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4804,9 +5174,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1g
        LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4821,9 +5192,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoic
        LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKSignedRawInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4831,33 +5203,16 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNo
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b, int64_t c) {
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
-       LDKRawInvoice a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = RawInvoice_clone(&a_conv);
-       ret->a = a_conv;
-       LDKThirtyTwoBytes b_ref;
-       CHECK((*env)->GetArrayLength(env, b) == 32);
-       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
-       ret->b = b_ref;
-       LDKInvoiceSignature c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = InvoiceSignature_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
        return RawInvoice_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4880,9 +5235,10 @@ static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignature
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4896,9 +5252,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErro
        LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPayeePubKey res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4941,9 +5298,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimesta
        LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPositiveTimestamp res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4973,9 +5331,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemantic
        LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -4991,9 +5350,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCrea
        LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDescription res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5009,9 +5369,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreat
        LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKExpiryTime res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5027,9 +5388,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCre
        LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPrivateRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5061,18 +5423,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorU
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelMonitorUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5082,18 +5446,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecod
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -5108,34 +5474,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpda
        LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKMonitorUpdateError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
-       LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
-       LDKOutPoint a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = OutPoint_clone(&a_conv);
-       ret->a = a_conv;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
        return OutPoint_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
        LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5154,16 +5508,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScript
        return ret_arr;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
-       LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
-       ret->a = a;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = (*env)->GetArrayLength(env, b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5195,7 +5539,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32Script
                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_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5210,29 +5556,6 @@ static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const L
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32ScriptZZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
-       else
-               b_constr.data = NULL;
-       int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
-       for (size_t v = 0; v < b_constr.datalen; v++) {
-               int64_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
-               b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
-               b_constr.data[v] = b_conv_21_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -5249,7 +5572,8 @@ static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32Scr
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t v = 0; v < ret_var.datalen; v++) {
                LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
@@ -5271,7 +5595,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_
                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_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5434,12 +5760,12 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *en
        LDKEvent_PaymentSent_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
        CHECK(LDKEvent_PaymentSent_class != NULL);
-       LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B)V");
+       LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
        CHECK(LDKEvent_PaymentSent_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, "<init>", "([BZJZ[JJ)V");
+       LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
        CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
        LDKEvent_PendingHTLCsForwardable_class =
                (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
@@ -5485,36 +5811,51 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JN
                        return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
                }
                case LDKEvent_PaymentSent: {
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
                        int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
                        (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
                        int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
                        (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
-                       return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr, payment_hash_arr);
+                       uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+                       return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
                }
                case LDKEvent_PaymentPathFailed: {
+                       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+                       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
                        int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
                        (*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_tArray path_arr = NULL;
+                       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];
+                               uint64_t path_conv_10_ref = 0;
                                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_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);
                        uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
-                       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, short_channel_id_ref);
+                       LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+                       uint64_t retry_ref = 0;
+                       if ((uint64_t)retry_var.inner > 4096) {
+                               CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               retry_ref = (uint64_t)retry_var.inner & ~1;
+                       }
+                       return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
                }
                case LDKEvent_PendingHTLCsForwardable: {
                        return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
                }
                case LDKEvent_SpendableOutputs: {
                        LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
-                       int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
+                       int64_tArray outputs_arr = NULL;
+                       outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
                        int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
                        for (size_t b = 0; b < outputs_var.datalen; b++) {
                                uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
@@ -5554,7 +5895,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv
                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];
-                       LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
                        arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5569,14 +5912,6 @@ static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
-       LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
-       ret->a = a;
-       LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
-       b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5606,7 +5941,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZ
                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_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5621,29 +5958,6 @@ static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDK
        }
        return ret;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK((*env)->GetArrayLength(env, a) == 32);
-       (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32TxOutZZ b_constr;
-       b_constr.datalen = (*env)->GetArrayLength(env, b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
-       else
-               b_constr.data = NULL;
-       int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
-       for (size_t u = 0; u < b_constr.datalen; u++) {
-               int64_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
-               b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
-               b_constr.data[u] = b_conv_20_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -5660,7 +5974,8 @@ static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOu
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t u = 0; u < ret_var.datalen; u++) {
                LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
@@ -5682,7 +5997,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_
                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_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5755,7 +6072,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1BalanceZ_1new(JNIE
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
                        arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5785,9 +6104,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockH
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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) {
@@ -5802,22 +6122,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningEr
        LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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;
-}
 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -5833,7 +6143,7 @@ static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTy
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
-       LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
+       LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
        *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
        return (uint64_t)ret_ret;
 }
@@ -5848,7 +6158,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1PublicKey
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -5875,39 +6187,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningEr
        LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b, int64_t c) {
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
-       LDKChannelAnnouncement a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = ChannelAnnouncement_clone(&a_conv);
-       ret->a = a_conv;
-       LDKChannelUpdate b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelUpdate_clone(&b_conv);
-       ret->b = b_conv;
-       LDKChannelUpdate c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = ChannelUpdate_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
        return ChannelAnnouncement_clone(&tuple->a);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5920,9 +6215,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5935,9 +6231,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -5954,7 +6251,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAn
                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];
-                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
                        arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -6011,9 +6310,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHa
        LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6028,9 +6328,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleE
        LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6045,9 +6346,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleE
        LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6057,18 +6359,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErr
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeId res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKAccess_JCalls {
@@ -6112,7 +6416,9 @@ LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, cons
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
        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);
@@ -6146,7 +6452,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env,
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
        unsigned char genesis_hash_arr[32];
        CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
        (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
@@ -6176,7 +6484,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1f
        LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_AccessZ_Some: {
-                       LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
+                       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) {
@@ -6198,18 +6506,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChan
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDirectionalChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6219,18 +6529,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDeco
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6240,18 +6552,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDeco
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoutingFees res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6261,18 +6575,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncemen
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncementInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -6302,18 +6618,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeE
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6323,18 +6641,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDec
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNetworkGraph res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
@@ -6358,7 +6678,8 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddres
        switch(obj->tag) {
                case LDKCOption_CVec_NetAddressZZ_Some: {
                        LDKCVec_NetAddressZ some_var = obj->some;
-                       int64_tArray some_arr = (*env)->NewLongArray(env, some_var.datalen);
+                       int64_tArray some_arr = NULL;
+                       some_arr = (*env)->NewLongArray(env, some_var.datalen);
                        int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
                        for (size_t m = 0; m < some_var.datalen; m++) {
                                uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
@@ -6373,40 +6694,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddres
                default: abort();
        }
 }
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(val->result_ok);
-       uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
-       return res_ref;
-}
-JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(!val->result_ok);
-       return *val->contents.err;
-}
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *res_conv = (*val->contents.result);
-       *res_conv = CResult_NetAddressu8Z_clone(res_conv);
-       return (uint64_t)res_conv;
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(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_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
        return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
 }
@@ -6420,9 +6707,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecod
        LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
@@ -6540,18 +6828,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDe
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAcceptChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6561,18 +6851,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSig
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAnnouncementSignatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6582,18 +6874,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestabl
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelReestablish res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6603,18 +6897,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDe
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6624,18 +6920,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFe
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSignedFeeRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6645,18 +6943,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSigne
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6666,18 +6966,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedD
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingCreated res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6687,18 +6989,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDe
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6708,18 +7012,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDe
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingLocked res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6729,18 +7035,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeError
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInit res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6750,18 +7058,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDeco
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOpenChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6771,18 +7081,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDec
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRevokeAndACK res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6792,18 +7104,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeE
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdown res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6813,18 +7127,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCD
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6834,18 +7150,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalfo
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6855,18 +7173,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecode
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6876,18 +7196,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHT
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFulfillHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6897,18 +7219,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDe
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateAddHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6918,18 +7242,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeError
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPing res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6939,18 +7265,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeError
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPong res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6960,18 +7288,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannel
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -6981,18 +7311,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnounce
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7002,18 +7334,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannel
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7023,18 +7357,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDe
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7044,18 +7380,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDec
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKErrorMessage res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7065,18 +7403,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnn
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7086,18 +7426,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncemen
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7107,18 +7449,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChann
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryShortChannelIds res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7128,18 +7472,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChann
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7149,18 +7495,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRan
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7170,18 +7518,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRan
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7191,18 +7541,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestamp
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKGossipTimestampFilter res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 static jclass LDKSignOrCreationError_SignError_class = NULL;
@@ -7241,9 +7593,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCr
        LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7311,9 +7664,10 @@ LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKWatchedOutput output_var = output;
+       uint64_t output_ref = 0;
        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;
+       output_ref = (uint64_t)output_var.inner;
        if (output_var.is_owned) {
                output_ref |= 1;
        }
@@ -7324,7 +7678,9 @@ LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
        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);
@@ -7361,7 +7717,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env,
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
@@ -7374,7 +7732,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1tx(JNIEnv *e
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        LDKWatchedOutput output_conv;
        output_conv.inner = (void*)(output & (~1));
        output_conv.is_owned = (output & 1) || (output == 0);
@@ -7405,7 +7765,7 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1f
        LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_FilterZ_Some: {
-                       LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
+                       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) {
@@ -7427,9 +7787,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMo
        LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKLockedChannelMonitor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
@@ -7512,7 +7873,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP
        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);
+               void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
+               CHECK_ACCESS(ret_conv_18_ptr);
+               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
                ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
                ret_constr.data[s] = ret_conv_18_conv;
        }
@@ -7549,13 +7912,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvide
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
        LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
-               *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
+               *ret_conv_18_copy = ret_var.data[s];
                uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
                ret_arr_ptr[s] = ret_conv_18_ref;
        }
@@ -7636,7 +8002,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv
        return (uint64_t)res_ptr;
 }
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
        LDKEvent* event_conv = (LDKEvent*)event;
        (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
 }
@@ -7673,7 +8041,7 @@ void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEve
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+       LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *handler_ret = handler;
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
@@ -7713,8 +8081,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIE
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
-       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
-       LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
+       void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
+       CHECK_ACCESS(handler_ptr);
+       LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
        if (handler_conv.free == LDKEventHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKEventHandler_JCalls_cloned(&handler_conv);
@@ -7821,7 +8193,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env,
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray block, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        LDKu8slice block_ref;
        block_ref.datalen = (*env)->GetArrayLength(env, block);
        block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
@@ -7830,7 +8204,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1connected(JNIEn
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1block_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -7876,7 +8252,8 @@ void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t
        int8_tArray header_arr = (*env)->NewByteArray(env, 80);
        (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
        LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
-       int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
+       int64_tArray txdata_arr = NULL;
+       txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
        int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
        for (size_t c = 0; c < txdata_var.datalen; c++) {
                LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
@@ -8010,7 +8387,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env
        return (uint64_t)res_ptr;
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -8024,7 +8403,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirm
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
@@ -8033,7 +8414,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transactions_1confirm
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
@@ -8042,7 +8425,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfir
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1best_1block_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
@@ -8051,15 +8436,19 @@ 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 *env, jclass clz, int64_t this_arg) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        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);
+       jobjectArray ret_arr = NULL;
+       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;
 }
@@ -8088,7 +8477,7 @@ static void LDKPersist_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -8097,36 +8486,48 @@ LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(con
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((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_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -8135,37 +8536,52 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcal
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = *update;
-       update_var = ChannelMonitorUpdate_clone(update);
-       CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
-       CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
-       if (update_var.is_owned) {
-               update_ref |= 1;
+       uint64_t update_ref = 0;
+       if ((uint64_t)update_var.inner > 4096) {
+               update_var = ChannelMonitorUpdate_clone(update);
+               CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               update_ref = (uint64_t)update_var.inner;
+               if (update_var.is_owned) {
+                       update_ref |= 1;
+               }
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
        }
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -8183,9 +8599,9 @@ static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
        atomic_init(&calls->refcnt, 1);
        DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
        calls->o = (*env)->NewWeakGlobalRef(env, o);
-       calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
+       calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
        CHECK(calls->persist_new_channel_meth != NULL);
-       calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
+       calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
        CHECK(calls->update_persisted_channel_meth != NULL);
 
        LDKPersist ret = {
@@ -8201,34 +8617,46 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env
        *res_ptr = LDKPersist_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitorUpdate update_conv;
        update_conv.inner = (void*)(update & (~1));
        update_conv.is_owned = false;
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
@@ -8287,17 +8715,19 @@ void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LD
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKOpenChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = OpenChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8324,17 +8754,19 @@ void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKAcceptChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AcceptChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8361,10 +8793,11 @@ void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingCreated msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingCreated_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8391,10 +8824,11 @@ void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8421,10 +8855,11 @@ void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKFundingLocked msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingLocked_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8451,18 +8886,20 @@ void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPub
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInitFeatures their_features_var = *their_features;
+       uint64_t their_features_ref = 0;
        their_features_var = InitFeatures_clone(their_features);
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKShutdown msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Shutdown_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8489,10 +8926,11 @@ void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKClosingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ClosingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8519,10 +8957,11 @@ void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateAddHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateAddHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8549,10 +8988,11 @@ void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFulfillHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFulfillHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8579,10 +9019,11 @@ void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFailHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8609,10 +9050,11 @@ void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFailMalformedHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailMalformedHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8639,10 +9081,11 @@ void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_ar
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKCommitmentSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = CommitmentSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8669,10 +9112,11 @@ void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKRevokeAndACK msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = RevokeAndACK_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8699,10 +9143,11 @@ void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKP
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKUpdateFee msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFee_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8729,10 +9174,11 @@ void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* t
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKAnnouncementSignatures msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AnnouncementSignatures_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8781,10 +9227,11 @@ void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPubl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInit msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Init_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8811,10 +9258,11 @@ void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKChannelReestablish msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelReestablish_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8841,10 +9289,11 @@ void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8871,10 +9320,11 @@ void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublic
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKErrorMessage msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ErrorMessage_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -8982,7 +9432,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1g
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1open_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -8997,7 +9449,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1accept_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9012,7 +9466,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1created(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9023,7 +9479,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9034,7 +9492,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9045,7 +9505,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1shutdown(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t their_features, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9059,7 +9521,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1closing_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9070,7 +9534,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1add_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9081,7 +9547,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fulfill_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9092,7 +9560,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9103,7 +9573,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9114,7 +9586,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9125,7 +9599,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1revoke_1and_1ack(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9136,7 +9612,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1update_1fee(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9147,7 +9625,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1announcement_1signatures(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9158,7 +9638,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9166,7 +9648,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1d
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9177,7 +9661,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1c
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1reestablish(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9188,7 +9674,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9199,7 +9687,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1error(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        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);
@@ -9252,10 +9742,11 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKNodeAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = NodeAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9266,7 +9757,9 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9283,10 +9776,11 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHand
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9297,7 +9791,9 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHand
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9314,10 +9810,11 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9328,7 +9825,9 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -9360,7 +9859,9 @@ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t h = 0; h < ret_constr.datalen; h++) {
                int64_t ret_conv_59 = ret_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
+               void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
+               CHECK_ACCESS(ret_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
                ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
                ret_constr.data[h] = ret_conv_59_conv;
        }
@@ -9421,10 +9922,11 @@ void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDK
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKInit init_var = *init;
+       uint64_t init_ref = 0;
        init_var = Init_clone(init);
        CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t init_ref = (uint64_t)init_var.inner;
+       init_ref = (uint64_t)init_var.inner;
        if (init_var.is_owned) {
                init_ref |= 1;
        }
@@ -9451,9 +9953,10 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKReplyChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9464,7 +9967,9 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9483,9 +9988,10 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKReplyShortChannelIdsEnd msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9496,7 +10002,9 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9515,9 +10023,10 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKQueryChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9528,7 +10037,9 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9547,9 +10058,10 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
        int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
        (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
        LDKQueryShortChannelIds msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -9560,7 +10072,9 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
        }
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9630,7 +10144,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1g
        return (int64_t)(res_ptr | 1);
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKNodeAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9640,7 +10156,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9650,7 +10168,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelUpdate msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -9660,9 +10180,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
@@ -9675,18 +10198,22 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_18_ref = 0;
                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;
+               ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
                if (ret_conv_18_var.is_owned) {
                        ret_conv_18_ref |= 1;
                }
@@ -9698,7 +10225,9 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9709,7 +10238,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1r
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9723,7 +10254,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9737,7 +10270,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9751,7 +10286,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1hand
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        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);
@@ -9806,7 +10343,9 @@ LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const voi
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
        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);
@@ -9840,7 +10379,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
        LDKu8slice buffer_ref;
        buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
        buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
@@ -9884,7 +10425,7 @@ LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jca
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
-       LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
+       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);
@@ -9895,7 +10436,9 @@ LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jca
                (*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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        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);
@@ -9927,7 +10470,9 @@ LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandle
        int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
        for (size_t z = 0; z < ret_constr.datalen; z++) {
                int64_t ret_conv_25 = ret_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
+               void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
+               CHECK_ACCESS(ret_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
                ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
                ret_constr.data[z] = ret_conv_25_conv;
        }
@@ -9976,8 +10521,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1ge
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+       void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
+       CHECK_ACCESS(msg_ptr);
+       LDKType msg_conv = *(LDKType*)(msg_ptr);
        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);
@@ -9991,9 +10540,12 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handl
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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++) {
                LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
@@ -10156,7 +10708,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JN
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = (*env)->GetArrayLength(env, data);
        data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
@@ -10166,12 +10720,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1dat
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
        return ret_val;
 }
@@ -10181,6 +10739,8 @@ typedef struct LDKScore_JCalls {
        JavaVM *vm;
        jweak o;
        jmethodID channel_penalty_msat_meth;
+       jmethodID payment_path_failed_meth;
+       jmethodID write_meth;
 } LDKScore_JCalls;
 static void LDKScore_JCalls_free(void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
@@ -10199,7 +10759,7 @@ static void LDKScore_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
+uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
        JNIEnv *env;
        jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
@@ -10208,9 +10768,27 @@ uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t shor
        } else {
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
+       LDKNodeId source_var = *source;
+       uint64_t source_ref = 0;
+       source_var = NodeId_clone(source);
+       CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       source_ref = (uint64_t)source_var.inner;
+       if (source_var.is_owned) {
+               source_ref |= 1;
+       }
+       LDKNodeId target_var = *target;
+       uint64_t target_ref = 0;
+       target_var = NodeId_clone(target);
+       CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       target_ref = (uint64_t)target_var.inner;
+       if (target_var.is_owned) {
+               target_ref |= 1;
+       }
        jobject obj = (*env)->NewLocalRef(env, j_calls->o);
        CHECK(obj != NULL);
-       int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id);
+       int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
        if ((*env)->ExceptionCheck(env)) {
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
@@ -10220,6 +10798,68 @@ uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t shor
        }
        return ret;
 }
+void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+       LDKScore_JCalls *j_calls = (LDKScore_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);
+       }
+       LDKCVec_RouteHopZ path_var = path;
+       int64_tArray path_arr = NULL;
+       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];
+               uint64_t path_conv_10_ref = 0;
+               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.
+               path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
+               if (path_conv_10_var.is_owned) {
+                       path_conv_10_ref |= 1;
+               }
+               path_arr_ptr[k] = path_conv_10_ref;
+       }
+       (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
+       FREE(path_var.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
+       }
+       if (get_jenv_res == JNI_EDETACHED) {
+               DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+       }
+}
+LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
+       LDKScore_JCalls *j_calls = (LDKScore_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 LDKScore 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 LDKScore_JCalls_cloned(LDKScore* new_obj) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
        atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
@@ -10231,12 +10871,18 @@ static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
        atomic_init(&calls->refcnt, 1);
        DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
        calls->o = (*env)->NewWeakGlobalRef(env, o);
-       calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(J)J");
+       calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJ)J");
        CHECK(calls->channel_penalty_msat_meth != NULL);
+       calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
+       CHECK(calls->payment_path_failed_meth != NULL);
+       calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
+       CHECK(calls->write_meth != NULL);
 
        LDKScore ret = {
                .this_arg = (void*) calls,
                .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
+               .payment_path_failed = payment_path_failed_LDKScore_jcall,
+               .write = write_LDKScore_jcall,
                .free = LDKScore_JCalls_free,
        };
        return ret;
@@ -10246,12 +10892,54 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env,
        *res_ptr = LDKScore_init(env, clz, o);
        return (uint64_t)res_ptr;
 }
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
-       LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
-       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       LDKNodeId source_conv;
+       source_conv.inner = (void*)(source & (~1));
+       source_conv.is_owned = false;
+       LDKNodeId target_conv;
+       target_conv.inner = (void*)(target & (~1));
+       target_conv.is_owned = false;
+       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
        return ret_val;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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);
+       (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+}
+
 typedef struct LDKChannelManagerPersister_JCalls {
        atomic_size_t refcnt;
        JavaVM *vm;
@@ -10285,10 +10973,11 @@ LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const voi
                DO_ASSERT(get_jenv_res == JNI_OK);
        }
        LDKChannelManager channel_manager_var = *channel_manager;
+       uint64_t channel_manager_ref = 0;
        // Warning: we may need a move here but no clone is available for LDKChannelManager
        CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
+       channel_manager_ref = (uint64_t)channel_manager_var.inner;
        if (channel_manager_var.is_owned) {
                channel_manager_ref |= 1;
        }
@@ -10299,7 +10988,9 @@ LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const voi
                (*env)->ExceptionDescribe(env);
                (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
        }
-       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
        if (get_jenv_res == JNI_EDETACHED) {
                DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
@@ -10333,7 +11024,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_
        return (uint64_t)res_ptr;
 }
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
-       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
        LDKChannelManager channel_manager_conv;
        channel_manager_conv.inner = (void*)(channel_manager & (~1));
        channel_manager_conv.is_owned = false;
@@ -10388,44 +11081,452 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr
                default: abort();
        }
 }
-JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
-       LDKStr ret_str = _ldk_get_compiled_version();
-       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
-       Str_free(ret_str);
-       return ret_conv;
-}
-
-JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
-       LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
-       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
-       Str_free(ret_str);
-       return ret_conv;
+typedef struct LDKPayer_JCalls {
+       atomic_size_t refcnt;
+       JavaVM *vm;
+       jweak o;
+       jmethodID node_id_meth;
+       jmethodID first_hops_meth;
+       jmethodID send_payment_meth;
+       jmethodID retry_payment_meth;
+} LDKPayer_JCalls;
+static void LDKPayer_JCalls_free(void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
 }
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
-       LDKTransaction _res_ref;
-       _res_ref.datalen = (*env)->GetArrayLength(env, _res);
-       _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
-       (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
-       _res_ref.data_is_owned = true;
-       Transaction_free(_res_ref);
+LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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->node_id_meth);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
+       }
+       LDKPublicKey ret_ref;
+       CHECK((*env)->GetArrayLength(env, ret) == 33);
+       (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
+       if (get_jenv_res == JNI_EDETACHED) {
+               DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
+       }
+       return ret_ref;
 }
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
-       LDKCVec_u8Z script_pubkey_ref;
-       script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
-       script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
-       (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
-       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
-       *ret_ref = TxOut_new(script_pubkey_ref, value);
-       return (uint64_t)ret_ref;
+LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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->first_hops_meth);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
+       }
+       LDKCVec_ChannelDetailsZ ret_constr;
+       ret_constr.datalen = (*env)->GetArrayLength(env, ret);
+       if (ret_constr.datalen > 0)
+               ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               ret_constr.data = NULL;
+       int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
+       for (size_t q = 0; q < ret_constr.datalen; q++) {
+               int64_t ret_conv_16 = ret_vals[q];
+               LDKChannelDetails ret_conv_16_conv;
+               ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
+               ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
+               ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
+               ret_constr.data[q] = ret_conv_16_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;
 }
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       TxOut_free(_res_conv);
+LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
+       int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((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_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_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);
+       }
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
+       (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((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 LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
+       jclass c = (*env)->GetObjectClass(env, o);
+       CHECK(c != NULL);
+       LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+       calls->o = (*env)->NewWeakGlobalRef(env, o);
+       calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
+       CHECK(calls->node_id_meth != NULL);
+       calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
+       CHECK(calls->first_hops_meth != NULL);
+       calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
+       CHECK(calls->send_payment_meth != NULL);
+       calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
+       CHECK(calls->retry_payment_meth != NULL);
+
+       LDKPayer ret = {
+               .this_arg = (void*) calls,
+               .node_id = node_id_LDKPayer_jcall,
+               .first_hops = first_hops_LDKPayer_jcall,
+               .send_payment = send_payment_LDKPayer_jcall,
+               .retry_payment = retry_payment_LDKPayer_jcall,
+               .free = LDKPayer_JCalls_free,
+       };
+       return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
+       LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *res_ptr = LDKPayer_init(env, clz, o);
+       return (uint64_t)res_ptr;
+}
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
+       int64_tArray ret_arr = NULL;
+       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++) {
+               LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
+               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.
+               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 int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_hash_ref;
+       CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
+       (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
+       LDKThirtyTwoBytes payment_secret_ref;
+       CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
+       (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
+       LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
+       LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
+       return (uint64_t)ret_conv;
+}
+
+typedef struct LDKRouter_JCalls {
+       atomic_size_t refcnt;
+       JavaVM *vm;
+       jweak o;
+       jmethodID find_route_meth;
+} LDKRouter_JCalls;
+static void LDKRouter_JCalls_free(void* this_arg) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_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_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_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 payer_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
+       LDKRouteParameters params_var = *params;
+       uint64_t params_ref = 0;
+       params_var = RouteParameters_clone(params);
+       CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       params_ref = (uint64_t)params_var.inner;
+       if (params_var.is_owned) {
+               params_ref |= 1;
+       }
+       LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
+       int64_tArray first_hops_arr = NULL;
+       if (first_hops != NULL) {
+               LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
+               first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
+               int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
+               for (size_t q = 0; q < first_hops_var.datalen; q++) {
+                       LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
+                       uint64_t first_hops_conv_16_ref = 0;
+                       CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
+                       if (first_hops_conv_16_var.is_owned) {
+                               first_hops_conv_16_ref |= 1;
+                       }
+                       first_hops_arr_ptr[q] = first_hops_conv_16_ref;
+               }
+               (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
+       }
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_scorer = ((uint64_t)scorer) | 1;
+       jobject obj = (*env)->NewLocalRef(env, j_calls->o);
+       CHECK(obj != NULL);
+       uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
+       if ((*env)->ExceptionCheck(env)) {
+               (*env)->ExceptionDescribe(env);
+               (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
+       }
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
+       ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((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 LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
+       jclass c = (*env)->GetObjectClass(env, o);
+       CHECK(c != NULL);
+       LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
+       calls->o = (*env)->NewWeakGlobalRef(env, o);
+       calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
+       CHECK(calls->find_route_meth != NULL);
+
+       LDKRouter ret = {
+               .this_arg = (void*) calls,
+               .find_route = find_route_LDKRouter_jcall,
+               .free = LDKRouter_JCalls_free,
+       };
+       return ret;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
+       LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *res_ptr = LDKRouter_init(env, clz, o);
+       return (uint64_t)res_ptr;
+}
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t params, int64_tArray first_hops, int64_t scorer) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
+       LDKPublicKey payer_ref;
+       CHECK((*env)->GetArrayLength(env, payer) == 33);
+       (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
+       LDKCVec_ChannelDetailsZ first_hops_constr;
+       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
+       if (first_hops != NULL) {
+               first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
+               if (first_hops_constr.datalen > 0)
+                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+               else
+                       first_hops_constr.data = NULL;
+               int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
+               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
+                       int64_t first_hops_conv_16 = first_hops_vals[q];
+                       LDKChannelDetails first_hops_conv_16_conv;
+                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
+                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
+                       first_hops_constr.data[q] = first_hops_conv_16_conv;
+               }
+               (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
+               first_hops_ptr = &first_hops_constr;
+       }
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
+       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
+       *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
+       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
+       LDKStr ret_str = _ldk_get_compiled_version();
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
+       LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
+       LDKTransaction _res_ref;
+       _res_ref.datalen = (*env)->GetArrayLength(env, _res);
+       _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
+       (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
+       _res_ref.data_is_owned = true;
+       Transaction_free(_res_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
+       LDKCVec_u8Z script_pubkey_ref;
+       script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
+       script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
+       (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
+       LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+       *ret_ref = TxOut_new(script_pubkey_ref, value);
+       return (uint64_t)ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
+       FREE((void*)_res);
+       TxOut_free(_res_conv);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
@@ -10458,7 +11559,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SecretKeyErrorZ_free(_res_conv);
 }
@@ -10481,7 +11584,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PublicKeyErrorZ_free(_res_conv);
 }
@@ -10515,7 +11620,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
 }
@@ -10549,7 +11656,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
 }
@@ -10580,7 +11689,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysErrorZ_free(_res_conv);
 }
@@ -10608,7 +11719,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u32Z_free(_res_conv);
 }
@@ -10643,7 +11756,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommit
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
 }
@@ -10677,7 +11792,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChanne
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -10711,7 +11828,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransaction
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -10762,7 +11881,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10796,7 +11917,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTra
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10826,7 +11949,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTran
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
 }
@@ -10853,7 +11978,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransact
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -10883,7 +12010,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentT
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
 }
@@ -10915,7 +12044,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
@@ -10949,7 +12080,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
 }
@@ -10975,7 +12108,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInva
        LDKInvalidShutdownScript e_conv;
        e_conv.inner = (void*)(e & (~1));
        e_conv.is_owned = (e & 1) || (e == 0);
-       // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
+       e_conv = InvalidShutdownScript_clone(&e_conv);
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
        *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
        return (uint64_t)ret_conv;
@@ -10983,11 +12116,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInva
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
+       *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
        LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
        *ret_conv = CResult_NoneErrorZ_ok();
@@ -11003,7 +12145,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JN
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneErrorZ_free(_res_conv);
 }
@@ -11037,7 +12181,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteHopDecodeErrorZ_free(_res_conv);
 }
@@ -11119,7 +12265,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteDecodeErrorZ_free(_res_conv);
 }
@@ -11131,52 +12279,40 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_some(o);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteParameters o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteParameters_clone(&o_conv);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_none();
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
-       COption_u64Z_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = COption_u64Z_clone(orig_conv);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+       CResult_RouteParametersDecodeErrorZ_free(_res_conv);
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
-       LDKCVec_ChannelDetailsZ _res_constr;
-       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
-       if (_res_constr.datalen > 0)
-               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-       else
-               _res_constr.data = NULL;
-       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
-       for (size_t q = 0; q < _res_constr.datalen; q++) {
-               int64_t _res_conv_16 = _res_vals[q];
-               LDKChannelDetails _res_conv_16_conv;
-               _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
-               _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
-               _res_constr.data[q] = _res_conv_16_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
-       CVec_ChannelDetailsZ_free(_res_constr);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
@@ -11198,11 +12334,188 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv
        CVec_RouteHintZ_free(_res_constr);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKRoute o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = Route_clone(&o_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_some(o);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_none();
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
+       FREE((void*)_res);
+       COption_u64Z_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = COption_u64Z_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Payee_clone(&o_conv);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PayeeDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
+       LDKCVec_RouteHintHopZ _res_constr;
+       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               _res_constr.data = NULL;
+       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
+       for (size_t o = 0; o < _res_constr.datalen; o++) {
+               int64_t _res_conv_14 = _res_vals[o];
+               LDKRouteHintHop _res_conv_14_conv;
+               _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
+               _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
+               _res_constr.data[o] = _res_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
+       CVec_RouteHintHopZ_free(_res_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteHint o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHint_clone(&o_conv);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRouteHintHop o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHintHop_clone(&o_conv);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
+       LDKCVec_ChannelDetailsZ _res_constr;
+       _res_constr.datalen = (*env)->GetArrayLength(env, _res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               _res_constr.data = NULL;
+       int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
+       for (size_t q = 0; q < _res_constr.datalen; q++) {
+               int64_t _res_conv_16 = _res_vals[q];
+               LDKChannelDetails _res_conv_16_conv;
+               _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
+               _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
+               _res_constr.data[q] = _res_conv_16_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
+       CVec_ChannelDetailsZ_free(_res_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRoute o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Route_clone(&o_conv);
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
        *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
        return (uint64_t)ret_conv;
@@ -11220,7 +12533,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteLightningErrorZ_free(_res_conv);
 }
@@ -11233,7 +12548,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
        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);
@@ -11249,7 +12566,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxOutAccessErrorZ_free(_res_conv);
 }
@@ -11281,7 +12600,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_usizeTransactionZ_free(_res_conv);
 }
@@ -11296,7 +12617,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactio
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t c = 0; c < _res_constr.datalen; c++) {
                int64_t _res_conv_28 = _res_vals[c];
-               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
+               void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
+               CHECK_ACCESS(_res_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
                FREE((void*)_res_conv_28);
                _res_constr.data[c] = _res_conv_28_conv;
        }
@@ -11336,7 +12659,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitor
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
 }
@@ -11358,7 +12683,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIE
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                int64_t _res_conv_14 = _res_vals[o];
-               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
+               void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
+               CHECK_ACCESS(_res_conv_14_ptr);
+               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
                FREE((void*)_res_conv_14);
                _res_constr.data[o] = _res_conv_14_conv;
        }
@@ -11367,7 +12694,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
        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);
@@ -11384,7 +12713,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
 }
@@ -11398,7 +12729,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTran
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
        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);
@@ -11415,7 +12748,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1no
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        COption_NetworkUpdateZ_free(_res_conv);
 }
@@ -11438,7 +12773,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescripto
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t b = 0; b < _res_constr.datalen; b++) {
                int64_t _res_conv_27 = _res_vals[b];
-               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
+               void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
+               CHECK_ACCESS(_res_conv_27_ptr);
+               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
                FREE((void*)_res_conv_27);
                _res_constr.data[b] = _res_conv_27_conv;
        }
@@ -11456,7 +12793,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t s = 0; s < _res_constr.datalen; s++) {
                int64_t _res_conv_18 = _res_vals[s];
-               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
+               void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
+               CHECK_ACCESS(_res_conv_18_ptr);
+               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
                FREE((void*)_res_conv_18);
                _res_constr.data[s] = _res_conv_18_conv;
        }
@@ -11486,7 +12825,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11513,7 +12854,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11540,7 +12883,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDec
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11567,11 +12912,71 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDec
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKScoringParameters 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 LDKScoringParameters
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
+       LDKScorer 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 LDKScorer
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScorerDecodeErrorZ_free(_res_conv);
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
        LDKDelayedPaymentOutputDescriptor o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -11594,7 +12999,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutp
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11628,7 +13035,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutpu
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11641,7 +13050,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
        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);
@@ -11660,7 +13071,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDes
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -11686,7 +13099,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNI
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneNoneZ_free(_res_conv);
 }
@@ -11729,13 +13144,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1Sig
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
        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);
@@ -11750,7 +13169,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1Signature
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
@@ -11779,7 +13200,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1er
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignatureNoneZ_free(_res_conv);
 }
@@ -11792,7 +13215,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1cl
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSign o_conv = *(LDKSign*)(o_ptr);
        if (o_conv.free == LDKSign_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSign_JCalls_cloned(&o_conv);
@@ -11814,7 +13239,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignDecodeErrorZ_free(_res_conv);
 }
@@ -11851,7 +13278,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatu
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RecoverableSignatureNoneZ_free(_res_conv);
 }
@@ -11909,7 +13338,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
 }
@@ -11943,7 +13374,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
 }
@@ -11965,7 +13398,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_7 = _res_vals[h];
-               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -11992,7 +13427,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TransactionNoneZ_free(_res_conv);
 }
@@ -12026,7 +13463,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
 }
@@ -12041,7 +13480,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChanne
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t j = 0; j < _res_constr.datalen; j++) {
                int64_t _res_conv_35 = _res_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
+               void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
+               CHECK_ACCESS(_res_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
                FREE((void*)_res_conv_35);
                _res_constr.data[j] = _res_conv_35_conv;
        }
@@ -12059,7 +13500,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
        int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
        for (size_t j = 0; j < o_constr.datalen; j++) {
                int64_t o_conv_35 = o_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
+               void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
+               CHECK_ACCESS(o_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
                o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
                o_constr.data[j] = o_conv_35_conv;
        }
@@ -12078,7 +13521,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
 }
@@ -12090,40 +13535,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Blo
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_PaymentIdDecodeErrorZ_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
        LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
        *ret_copy = COption_u16Z_some(o);
@@ -12140,7 +13551,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u16Z_free(_res_conv);
 }
@@ -12160,7 +13573,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -12169,7 +13584,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneAPIErrorZ_free(_res_conv);
 }
@@ -12191,7 +13608,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t w = 0; w < _res_constr.datalen; w++) {
                int64_t _res_conv_22 = _res_vals[w];
-               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
+               void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
+               CHECK_ACCESS(_res_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
                FREE((void*)_res_conv_22);
                _res_constr.data[w] = _res_conv_22_conv;
        }
@@ -12209,7 +13628,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t k = 0; k < _res_constr.datalen; k++) {
                int64_t _res_conv_10 = _res_vals[k];
-               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
+               void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
+               CHECK_ACCESS(_res_conv_10_ptr);
+               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
                FREE((void*)_res_conv_10);
                _res_constr.data[k] = _res_conv_10_conv;
        }
@@ -12227,7 +13648,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1o
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
        LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
        *ret_conv = CResult__u832APIErrorZ_err(e_conv);
@@ -12236,7 +13659,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1e
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult__u832APIErrorZ_free(_res_conv);
 }
@@ -12248,18 +13673,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1c
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK((*env)->GetArrayLength(env, o) == 32);
+       (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
-       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
+       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
        return (uint64_t)ret_conv;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
        *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
@@ -12268,7 +13694,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
 }
@@ -12287,7 +13715,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        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);
@@ -12296,7 +13726,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFai
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePaymentSendFailureZ_free(_res_conv);
 }
@@ -12315,28 +13747,31 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPayment
        return ((uint64_t)ret_conv);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
        LDKThirtyTwoBytes a_ref;
        CHECK((*env)->GetArrayLength(env, a) == 32);
        (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
+       LDKThirtyTwoBytes b_ref;
+       CHECK((*env)->GetArrayLength(env, b) == 32);
+       (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
        LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
+       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
        return ((uint64_t)ret_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
-       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
        o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
@@ -12344,7 +13779,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHa
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
@@ -12353,7 +13790,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
 }
@@ -12375,7 +13814,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t m = 0; m < _res_constr.datalen; m++) {
                int64_t _res_conv_12 = _res_vals[m];
-               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
+               void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
+               CHECK_ACCESS(_res_conv_12_ptr);
+               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
                FREE((void*)_res_conv_12);
                _res_constr.data[m] = _res_conv_12_conv;
        }
@@ -12404,7 +13845,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPayment
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
 }
@@ -12419,7 +13862,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -12428,7 +13873,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentSecretAPIErrorZ_free(_res_conv);
 }
@@ -12474,13 +13921,17 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
        // 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);
@@ -12499,7 +13950,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHash
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
 }
@@ -12526,7 +13979,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
 }
@@ -12560,7 +14015,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OutPointDecodeErrorZ_free(_res_conv);
 }
@@ -12573,7 +14030,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErro
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKType o_conv = *(LDKType*)(o_ptr);
        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);
@@ -12593,7 +14052,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
        FREE((void*)_res);
        COption_TypeZ_free(_res_conv);
 }
@@ -12607,7 +14068,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEn
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
        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);
@@ -12626,7 +14089,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDeco
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
 }
@@ -12638,6 +14103,41 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDeco
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK((*env)->GetArrayLength(env, o) == 32);
+       (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
+       e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PaymentIdPaymentErrorZ_free(_res_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_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");
@@ -12653,7 +14153,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SiPrefixNoneZ_free(_res_conv);
 }
@@ -12683,7 +14185,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceNoneZ_free(_res_conv);
 }
@@ -12713,7 +14217,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignedRawInvoiceNoneZ_free(_res_conv);
 }
@@ -12751,7 +14257,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832In
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
 }
@@ -12775,7 +14283,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PayeePubKeyErrorZ_free(_res_conv);
 }
@@ -12825,7 +14335,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampC
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
 }
@@ -12852,7 +14364,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneSemanticErrorZ_free(_res_conv);
 }
@@ -12883,7 +14397,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSemanticErrorZ_free(_res_conv);
 }
@@ -12914,7 +14430,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreatio
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DescriptionCreationErrorZ_free(_res_conv);
 }
@@ -12945,7 +14463,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreation
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
 }
@@ -12976,7 +14496,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreati
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PrivateRouteCreationErrorZ_free(_res_conv);
 }
@@ -13004,7 +14526,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StringErrorZ_free(_res_conv);
 }
@@ -13031,7 +14555,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpda
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -13065,7 +14591,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -13095,7 +14623,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
 }
@@ -13130,7 +14660,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1n
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_OutPointScriptZ_free(_res_conv);
 }
@@ -13154,7 +14686,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JN
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32ScriptZ_free(_res_conv);
 }
@@ -13169,7 +14703,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1fr
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t v = 0; v < _res_constr.datalen; v++) {
                int64_t _res_conv_21 = _res_vals[v];
-               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
+               void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
+               CHECK_ACCESS(_res_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
                FREE((void*)_res_conv_21);
                _res_constr.data[v] = _res_conv_21_conv;
        }
@@ -13197,7 +14733,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
        int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
        for (size_t v = 0; v < b_constr.datalen; v++) {
                int64_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
+               void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
+               CHECK_ACCESS(b_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
                b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
                b_constr.data[v] = b_conv_21_conv;
        }
@@ -13209,7 +14747,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
 }
@@ -13224,7 +14764,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                int64_t _res_conv_40 = _res_vals[o];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
+               void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
+               CHECK_ACCESS(_res_conv_40_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
                FREE((void*)_res_conv_40);
                _res_constr.data[o] = _res_conv_40_conv;
        }
@@ -13242,7 +14784,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_7 = _res_vals[h];
-               LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -13277,7 +14821,9 @@ 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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
        b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
        LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
@@ -13286,7 +14832,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32TxOutZ_free(_res_conv);
 }
@@ -13301,7 +14849,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1fre
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t u = 0; u < _res_constr.datalen; u++) {
                int64_t _res_conv_20 = _res_vals[u];
-               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
+               void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
+               CHECK_ACCESS(_res_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
                FREE((void*)_res_conv_20);
                _res_constr.data[u] = _res_conv_20_conv;
        }
@@ -13329,7 +14879,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
        int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
        for (size_t u = 0; u < b_constr.datalen; u++) {
                int64_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
+               void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
+               CHECK_ACCESS(b_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
                b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
                b_constr.data[u] = b_conv_20_conv;
        }
@@ -13341,7 +14893,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
 }
@@ -13356,7 +14910,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tup
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t n = 0; n < _res_constr.datalen; n++) {
                int64_t _res_conv_39 = _res_vals[n];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
+               void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
+               CHECK_ACCESS(_res_conv_39_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
                FREE((void*)_res_conv_39);
                _res_constr.data[n] = _res_conv_39_conv;
        }
@@ -13374,7 +14930,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *e
        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);
+               void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
+               CHECK_ACCESS(_res_conv_9_ptr);
+               LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
                FREE((void*)_res_conv_9);
                _res_constr.data[j] = _res_conv_9_conv;
        }
@@ -13383,7 +14941,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *e
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
        o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
@@ -13402,7 +14962,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHash
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
 }
@@ -13432,7 +14994,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningError
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneLightningErrorZ_free(_res_conv);
 }
@@ -13455,7 +15019,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1ne
        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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKType b_conv = *(LDKType*)(b_ptr);
        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);
@@ -13467,7 +15033,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1ne
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PublicKeyTypeZ_free(_res_conv);
 }
@@ -13482,7 +15050,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t z = 0; z < _res_constr.datalen; z++) {
                int64_t _res_conv_25 = _res_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
+               void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
+               CHECK_ACCESS(_res_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
                FREE((void*)_res_conv_25);
                _res_constr.data[z] = _res_conv_25_conv;
        }
@@ -13508,7 +15078,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningError
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolLightningErrorZ_free(_res_conv);
 }
@@ -13547,7 +15119,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncemen
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
 }
@@ -13562,7 +15136,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnounce
        int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                int64_t _res_conv_59 = _res_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
+               void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
+               CHECK_ACCESS(_res_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
                FREE((void*)_res_conv_59);
                _res_constr.data[h] = _res_conv_59_conv;
        }
@@ -13628,7 +15204,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandl
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
 }
@@ -13658,7 +15236,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePeerHandleErrorZ_free(_res_conv);
 }
@@ -13688,7 +15268,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolPeerHandleErrorZ_free(_res_conv);
 }
@@ -13722,7 +15304,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeIdDecodeErrorZ_free(_res_conv);
 }
@@ -13735,7 +15319,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKAccess o_conv = *(LDKAccess*)(o_ptr);
        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);
@@ -13755,7 +15341,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
        FREE((void*)_res);
        COption_AccessZ_free(_res_conv);
 }
@@ -13782,7 +15370,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannel
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13816,7 +15406,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13850,7 +15442,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
 }
@@ -13884,7 +15478,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementIn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13934,7 +15530,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeInfoDecodeErrorZ_free(_res_conv);
 }
@@ -13968,7 +15566,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
 }
@@ -13990,7 +15590,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
        int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
        for (size_t m = 0; m < o_constr.datalen; m++) {
                int64_t o_conv_12 = o_vals[m];
-               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
+               void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
+               CHECK_ACCESS(o_conv_12_ptr);
+               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
                o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
                o_constr.data[m] = o_conv_12_conv;
        }
@@ -14010,7 +15612,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_CVec_NetAddressZZ_free(_res_conv);
 }
@@ -14023,68 +15627,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ
        return ret_ref;
 }
 
-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;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_err(e);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_NetAddressu8Z_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
-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;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
        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);
@@ -14103,7 +15649,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeEr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetAddressDecodeErrorZ_free(_res_conv);
 }
@@ -14213,7 +15761,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
 }
@@ -14247,7 +15797,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignat
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
 }
@@ -14281,7 +15833,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablish
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
 }
@@ -14315,7 +15869,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14349,7 +15905,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRa
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
 }
@@ -14383,7 +15941,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14417,7 +15977,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
 }
@@ -14451,7 +16013,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -14485,7 +16049,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingLockedDecodeErrorZ_free(_res_conv);
 }
@@ -14519,7 +16085,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitDecodeErrorZ_free(_res_conv);
 }
@@ -14553,7 +16121,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OpenChannelDecodeErrorZ_free(_res_conv);
 }
@@ -14587,7 +16157,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
 }
@@ -14621,7 +16193,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErro
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownDecodeErrorZ_free(_res_conv);
 }
@@ -14655,7 +16229,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDeco
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14689,7 +16265,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalforme
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14723,7 +16301,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErr
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
 }
@@ -14757,7 +16337,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14791,7 +16373,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -14825,7 +16409,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PingDecodeErrorZ_free(_res_conv);
 }
@@ -14859,7 +16445,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PongDecodeErrorZ_free(_res_conv);
 }
@@ -14893,7 +16481,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -14927,7 +16517,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncemen
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -14961,7 +16553,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpd
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -14995,7 +16589,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecod
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -15029,7 +16625,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecode
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
 }
@@ -15063,7 +16661,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnoun
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -15097,7 +16697,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDe
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -15131,7 +16733,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
 }
@@ -15165,7 +16769,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
 }
@@ -15199,7 +16805,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -15233,7 +16841,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeD
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -15267,7 +16877,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFil
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
 }
@@ -15290,7 +16902,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
        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);
@@ -15299,7 +16913,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
 }
@@ -15312,7 +16928,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreat
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKFilter o_conv = *(LDKFilter*)(o_ptr);
        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);
@@ -15332,7 +16950,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
        FREE((void*)_res);
        COption_FilterZ_free(_res_conv);
 }
@@ -15355,7 +16975,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonit
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_LockedChannelMonitorNoneZ_free(_res_conv);
 }
@@ -15381,7 +17003,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentPurpose_free(this_ptr_conv);
 }
@@ -15419,7 +17043,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ClosureReason_free(this_ptr_conv);
 }
@@ -15494,7 +17120,9 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JN
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Event_free(this_ptr_conv);
 }
@@ -15525,7 +17153,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
+       CHECK_ACCESS(purpose_ptr);
+       LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
        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);
@@ -15533,24 +17163,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JN
        return ret_ref;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_hash) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKThirtyTwoBytes payment_preimage_ref;
        CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
        (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
        LDKThirtyTwoBytes payment_hash_ref;
        CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
        (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
+       void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
+       CHECK_ACCESS(fee_paid_msat_ptr);
+       LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
+       fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
+       *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-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, int64_t short_channel_id) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        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);
+       void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
+       CHECK_ACCESS(network_update_ptr);
+       LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
        network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
        LDKCVec_RouteHopZ path_constr;
        path_constr.datalen = (*env)->GetArrayLength(env, path);
@@ -15568,10 +17210,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1faile
                path_constr.data[k] = path_conv_10_conv;
        }
        (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
-       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
+       void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
+       CHECK_ACCESS(short_channel_id_ptr);
+       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
        short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
+       LDKRouteParameters retry_conv;
+       retry_conv.inner = (void*)(retry & (~1));
+       retry_conv.is_owned = (retry & 1) || (retry == 0);
+       retry_conv = RouteParameters_clone(&retry_conv);
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
+       *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -15593,7 +17241,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(J
        int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
        for (size_t b = 0; b < outputs_constr.datalen; b++) {
                int64_t outputs_conv_27 = outputs_vals[b];
-               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
+               void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
+               CHECK_ACCESS(outputs_conv_27_ptr);
+               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
                outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
                outputs_constr.data[b] = outputs_conv_27_conv;
        }
@@ -15605,7 +17255,9 @@ 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);
+       void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
+       CHECK_ACCESS(fee_earned_msat_ptr);
+       LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
        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);
@@ -15617,7 +17269,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIE
        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);
+       void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
+       CHECK_ACCESS(reason_ptr);
+       LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
        reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
        *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
@@ -15651,7 +17305,9 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *en
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEvent_free(this_ptr_conv);
 }
@@ -15873,7 +17529,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1e
        LDKPublicKey node_id_ref;
        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);
+       void* action_ptr = (void*)(((uint64_t)action) & ~1);
+       CHECK_ACCESS(action_ptr);
+       LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
        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);
@@ -15925,28 +17583,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1rep
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEventsProvider_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventsProvider_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventHandler_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        APIError_free(this_ptr_conv);
 }
@@ -16098,7 +17764,9 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jcla
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Logger_free(this_ptr_conv);
 }
@@ -16157,9 +17825,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1o
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16171,9 +17840,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16182,9 +17852,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16320,9 +17991,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1t
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16334,9 +18006,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16345,9 +18018,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16468,9 +18142,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1clo
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
        LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16482,9 +18157,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16493,9 +18169,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
        LDKChannelConfig ret_var = ChannelConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16535,9 +18212,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1chann
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16560,9 +18238,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1chan
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16585,9 +18264,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1o
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16634,9 +18314,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env
        channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
        channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
        LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16648,9 +18329,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16659,9 +18341,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *e
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
        LDKUserConfig ret_var = UserConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16680,9 +18363,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *en
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16692,9 +18376,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *en
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
        LDKNetwork network_conv = LDKNetwork_from_java(env, network);
        LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16706,9 +18391,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, block_hash) == 32);
        (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
        LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16750,21 +18436,27 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Access_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Listen_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Confirm_free(this_ptr_conv);
 }
@@ -16787,14 +18479,18 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1per
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Watch_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Filter_free(this_ptr_conv);
 }
@@ -16830,9 +18526,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16884,9 +18581,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1new(JNIEnv *
        script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
        LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16898,9 +18596,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16917,7 +18616,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BroadcasterInterface_free(this_ptr_conv);
 }
@@ -16952,34 +18653,81 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNI
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        FeeEstimator_free(this_ptr_conv);
 }
 
-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);
-       FREE((void*)this_ptr);
-       Persist_free(this_ptr_conv);
-}
-
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKLockedChannelMonitor this_obj_conv;
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKMonitorUpdateId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       LockedChannelMonitor_free(this_obj_conv);
+       MonitorUpdateId_free(this_obj_conv);
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKChainMonitor this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       ChainMonitor_free(this_obj_conv);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKMonitorUpdateId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_ChainMonitor_1new(JNIEnv *env, jclass clz, int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
-       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKMonitorUpdateId o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = MonitorUpdateId_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKMonitorUpdateId a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKMonitorUpdateId b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Persist_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKLockedChannelMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockedChannelMonitor_free(this_obj_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKChainMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ChainMonitor_free(this_obj_conv);
+}
+
+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) {
+       void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
+       CHECK_ACCESS(chain_source_ptr);
+       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
        // 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
@@ -16988,30 +18736,39 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1new(JNIEnv *e
                        LDKFilter_JCalls_cloned(&chain_source_conv.some);
                }
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
+       void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
+       CHECK_ACCESS(feeest_ptr);
+       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
        if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&feeest_conv);
        }
-       LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
        if (persister_conv.free == LDKPersist_JCalls_free) {
                // 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, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17039,11 +18796,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1cla
        }
        (*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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = ret_var.data[j];
                uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
                ret_arr_ptr[j] = ret_conv_9_ref;
        }
@@ -17070,13 +18828,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1mo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t k = 0; k < ret_var.datalen; k++) {
                LDKOutPoint ret_conv_10_var = ret_var.data[k];
+               uint64_t ret_conv_10_ref = 0;
                CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
+               ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
                if (ret_conv_10_var.is_owned) {
                        ret_conv_10_ref |= 1;
                }
@@ -17087,11 +18847,28 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1mo
        return ret_arr;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
+       LDKChainMonitor this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorUpdateId completed_update_id_conv;
+       completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
+       completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
+       completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
+       LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+       *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
+       return (uint64_t)ret_conv;
+}
+
 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_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17100,7 +18877,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(J
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17109,7 +18886,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNI
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
+       LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
        *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17118,7 +18895,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsPro
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -17150,9 +18927,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17187,14 +18965,46 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEn
        MonitorUpdateError_free(this_obj_conv);
 }
 
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
+       jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr val_conv = java_to_owned_str(env, val);
+       MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new(JNIEnv *env, jclass clz, jstring a_arg) {
+       LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
+       LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKMonitorUpdateError orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17203,7 +19013,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(J
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MonitorEvent_free(this_ptr_conv);
 }
@@ -17238,6 +19050,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1t
        return ret_ref;
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+       *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(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_update_failed(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
+       LDKCVec_u8Z ret_var = MonitorEvent_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_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKHTLCUpdate this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -17250,9 +19093,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17282,7 +19126,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *en
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Balance_free(this_ptr_conv);
 }
@@ -17342,9 +19188,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17369,9 +19216,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1update_1mon
        LDKChannelMonitorUpdate updates_conv;
        updates_conv.inner = (void*)(updates & (~1));
        updates_conv.is_owned = false;
-       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
+       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
+       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
        *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
        return (uint64_t)ret_conv;
@@ -17399,7 +19252,8 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1o
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
@@ -17415,7 +19269,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
+       void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
+       if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
+       LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
        ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
 }
 
@@ -17424,11 +19280,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1a
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
@@ -17442,11 +19299,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1a
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t h = 0; h < ret_var.datalen; h++) {
                LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
+               *ret_conv_7_copy = ret_var.data[h];
                uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
                ret_arr_ptr[h] = ret_conv_7_ref;
        }
@@ -17459,9 +19317,12 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1l
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
        ;
        for (size_t i = 0; i < ret_var.datalen; i++) {
                LDKTransaction ret_conv_8_var = ret_var.data[i];
@@ -17470,6 +19331,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1l
                Transaction_free(ret_conv_8_var);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -17491,28 +19353,37 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
        (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17532,17 +19403,23 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1disconn
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -17567,28 +19444,37 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transa
        int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                int64_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
        (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17608,17 +19494,23 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1transaction_1u
        CHECK((*env)->GetArrayLength(env, txid) == 32);
        (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
        unsigned char (*txid_ref)[32] = &txid_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -17634,23 +19526,30 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1best_1
        CHECK((*env)->GetArrayLength(env, header) == 80);
        (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
        if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
@@ -17667,13 +19566,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1r
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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;
 }
@@ -17683,9 +19584,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1be
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17697,11 +19599,12 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1c
        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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = ret_var.data[j];
                uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
                ret_arr_ptr[j] = ret_conv_9_ref;
        }
@@ -17714,7 +19617,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMo
        LDKu8slice ser_ref;
        ser_ref.datalen = (*env)->GetArrayLength(env, ser);
        ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
-       LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
+       void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
+       if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
+       LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
        (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
@@ -17767,9 +19672,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
        (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
        LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17781,9 +19687,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17851,9 +19758,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17909,7 +19817,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor
        LDKDelayedPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -17975,7 +19885,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        LDKPublicKey per_commitment_point_arg_ref;
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
        LDKPublicKey revocation_pubkey_arg_ref;
        CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
@@ -17984,9 +19896,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
        (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17998,9 +19911,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescrip
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18040,9 +19954,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18064,7 +19979,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_
        LDKStaticPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -18108,15 +20025,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        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);
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18128,9 +20048,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18160,7 +20081,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescript
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SpendableOutputDescriptor_free(this_ptr_conv);
 }
@@ -18178,7 +20101,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1
        outpoint_conv.inner = (void*)(outpoint & (~1));
        outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
        outpoint_conv = OutPoint_clone(&outpoint_conv);
-       LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
+       void* output_ptr = (void*)(((uint64_t)output) & ~1);
+       CHECK_ACCESS(output_ptr);
+       LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
        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);
@@ -18229,28 +20154,36 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BaseSign_free(this_ptr_conv);
 }
 
 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSign* orig_conv = (LDKSign*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Sign_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        KeysInterface_free(this_ptr_conv);
 }
@@ -18381,9 +20314,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18413,9 +20347,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
        (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
        LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18427,9 +20362,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterpart
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18465,9 +20401,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1ou
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18479,9 +20416,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channe
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18526,7 +20464,7 @@ 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_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+       LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
        *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -18535,7 +20473,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JN
        LDKInMemorySigner this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -18574,9 +20512,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1new(JNIEnv *en
        (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
        unsigned char (*seed_ref)[32] = &seed_arr;
        LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18592,9 +20531,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1derive_1channe
        (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
        unsigned char (*params_ref)[32] = &params_arr;
        LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18614,7 +20554,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendab
        int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
        for (size_t b = 0; b < descriptors_constr.datalen; b++) {
                int64_t descriptors_conv_27 = descriptors_vals[b];
-               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
+               void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
+               CHECK_ACCESS(descriptors_conv_27_ptr);
+               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
                descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
                descriptors_constr.data[b] = descriptors_conv_27_conv;
        }
@@ -18628,7 +20570,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendab
        int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
        for (size_t h = 0; h < outputs_constr.datalen; h++) {
                int64_t outputs_conv_7 = outputs_vals[h];
-               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
+               void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
+               CHECK_ACCESS(outputs_conv_7_ptr);
+               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
                outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
                outputs_constr.data[h] = outputs_conv_7_conv;
        }
@@ -18646,72 +20590,11 @@ 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_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+       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_PaymentId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
-       LDKPaymentId this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       PaymentId_free(this_obj_conv);
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1hash(JNIEnv *env, jclass clz, int64_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = false;
-       int64_t ret_val = PaymentId_hash(&o_conv);
-       return ret_val;
-}
-
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
-       LDKPaymentId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKPaymentId ret_var = PaymentId_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 jboolean JNICALL Java_org_ldk_impl_bindings_PaymentId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
-       LDKPaymentId a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = false;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = false;
-       jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
-       return ret_val;
-}
-
-JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentId_1write(JNIEnv *env, jclass clz, int64_t obj) {
-       LDKPaymentId obj_conv;
-       obj_conv.inner = (void*)(obj & (~1));
-       obj_conv.is_owned = false;
-       LDKCVec_u8Z ret_var = PaymentId_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_PaymentId_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = PaymentId_read(ser_ref);
-       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
-       return (uint64_t)ret_conv;
-}
-
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKChannelManager this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -18747,9 +20630,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18774,9 +20658,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv
        best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
        best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
        LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18788,9 +20673,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18851,9 +20737,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1se
 
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18865,9 +20752,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18905,9 +20793,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1f
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18945,11 +20834,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1f
        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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -18978,9 +20870,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JN
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18992,9 +20885,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19032,9 +20926,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counte
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19057,11 +20952,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1fundin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -19091,7 +20989,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
 }
@@ -19125,7 +21025,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendab
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
 }
@@ -19189,7 +21091,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmat
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
 }
@@ -19208,7 +21112,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1cl
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
        val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
 }
@@ -19285,17 +21191,26 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv
        funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
        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);
+       void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
+       CHECK_ACCESS(short_channel_id_arg_ptr);
+       LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
        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);
+       void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
+       CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
+       LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
+       void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
+       CHECK_ACCESS(confirmations_required_arg_ptr);
+       LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
        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);
+       void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
+       CHECK_ACCESS(force_close_spend_delay_arg_ptr);
+       LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
        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_channel_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19307,9 +21222,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19318,7 +21234,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEn
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentSendFailure_free(this_ptr_conv);
 }
@@ -19332,7 +21250,9 @@ 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);
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
        a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
        *ret_copy = PaymentSendFailure_parameter_error(a_conv);
@@ -19350,7 +21270,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1p
        int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
        for (size_t w = 0; w < a_constr.datalen; w++) {
                int64_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
+               void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
+               CHECK_ACCESS(a_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
                a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
                a_constr.data[w] = a_conv_22_conv;
        }
@@ -19371,7 +21293,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1fa
        int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
        for (size_t k = 0; k < a_constr.datalen; k++) {
                int64_t a_conv_10 = a_vals[k];
-               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
+               void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
+               CHECK_ACCESS(a_conv_10_ptr);
+               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
                a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
                a_constr.data[k] = a_conv_10_conv;
        }
@@ -19382,49 +21306,67 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1fa
        return ret_ref;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
-       LDKCVec_CResult_NoneAPIErrorZZ a_constr;
-       a_constr.datalen = (*env)->GetArrayLength(env, a);
-       if (a_constr.datalen > 0)
-               a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
+       LDKCVec_CResult_NoneAPIErrorZZ results_constr;
+       results_constr.datalen = (*env)->GetArrayLength(env, results);
+       if (results_constr.datalen > 0)
+               results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
        else
-               a_constr.data = NULL;
-       int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
-       for (size_t w = 0; w < a_constr.datalen; w++) {
-               int64_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
-               a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
-               a_constr.data[w] = a_conv_22_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
+               results_constr.data = NULL;
+       int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
+       for (size_t w = 0; w < results_constr.datalen; w++) {
+               int64_t results_conv_22 = results_vals[w];
+               void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
+               CHECK_ACCESS(results_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
+               results_constr.data[w] = results_conv_22_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
+       LDKRouteParameters failed_paths_retry_conv;
+       failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
+       failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
+       failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
-       *ret_copy = PaymentSendFailure_partial_failure(a_constr);
+       *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv *env, jclass clz, int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t keys_manager, int64_t config, int64_t params) {
-       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
+       void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
+       CHECK_ACCESS(fee_est_ptr);
+       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
        if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
        }
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
        if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&chain_monitor_conv);
        }
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
        if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
@@ -19438,9 +21380,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1new(JNIEnv
        params_conv.is_owned = (params & 1) || (params == 0);
        params_conv = ChainParameters_clone(&params_conv);
        LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19452,9 +21395,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1curren
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19482,13 +21426,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -19504,13 +21450,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -19585,19 +21533,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payme
        return (uint64_t)ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int64_t payment_id) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRoute route_conv;
        route_conv.inner = (void*)(route & (~1));
        route_conv.is_owned = false;
-       LDKPaymentId payment_id_conv;
-       payment_id_conv.inner = (void*)(payment_id & (~1));
-       payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
-       payment_id_conv = PaymentId_clone(&payment_id_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK((*env)->GetArrayLength(env, payment_id) == 32);
+       (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
        LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
-       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
+       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
        return (uint64_t)ret_conv;
 }
 
@@ -19653,7 +21600,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1nod
        int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
        for (size_t m = 0; m < addresses_constr.datalen; m++) {
                int64_t addresses_conv_12 = addresses_vals[m];
-               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
+               void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
+               CHECK_ACCESS(addresses_conv_12_ptr);
+               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
                addresses_constr.data[m] = addresses_conv_12_conv;
        }
        (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
@@ -19706,21 +21655,13 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1ou
        return ret_arr;
 }
 
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t highest_applied_update_id) {
-       LDKChannelManager this_arg_conv;
-       this_arg_conv.inner = (void*)(this_arg & (~1));
-       this_arg_conv.is_owned = false;
-       LDKOutPoint funding_txo_conv;
-       funding_txo_conv.inner = (void*)(funding_txo & (~1));
-       funding_txo_conv.is_owned = false;
-       ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
-}
-
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
        LDKChannelManager this_arg_conv;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
        LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
        *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
@@ -19734,7 +21675,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inb
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        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);
@@ -19745,7 +21688,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19754,7 +21697,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsP
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19763,7 +21706,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19772,7 +21715,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19797,9 +21740,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1be
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19810,7 +21754,7 @@ 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_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -19837,7 +21781,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19845,7 +21790,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1k
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
        if (val_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&val_conv);
@@ -19857,7 +21804,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19865,7 +21813,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1f
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
        if (val_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&val_conv);
@@ -19877,7 +21827,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19885,7 +21836,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1c
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKWatch val_conv = *(LDKWatch*)(val_ptr);
        if (val_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&val_conv);
@@ -19897,7 +21850,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19905,7 +21859,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1t
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
        if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&val_conv);
@@ -19917,7 +21873,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -19925,7 +21882,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1l
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKLogger val_conv = *(LDKLogger*)(val_ptr);
        if (val_conv.free == LDKLogger_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKLogger_JCalls_cloned(&val_conv);
@@ -19938,9 +21897,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19959,27 +21919,37 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1d
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
        }
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
        if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
        }
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
        if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKWatch_JCalls_cloned(&chain_monitor_conv);
        }
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
        if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
@@ -20004,9 +21974,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new
        }
        (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
        LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20039,9 +22010,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20060,9 +22032,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20086,9 +22059,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jcla
        features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
        features_arg_conv = InitFeatures_clone(&features_arg_conv);
        LDKInit ret_var = Init_new(features_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20100,9 +22074,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInit ret_var = Init_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20159,9 +22134,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *e
        (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
        LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
        LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20173,9 +22149,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20221,9 +22198,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *en
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
        LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20235,9 +22213,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPing ret_var = Ping_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20268,9 +22247,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *en
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
        LDKPong ret_var = Pong_new(byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20282,9 +22262,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jc
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPong ret_var = Pong_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20605,9 +22586,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20864,9 +22846,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20963,9 +22946,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
        LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20977,9 +22961,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21039,9 +23024,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *
        CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
        LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21053,9 +23039,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21115,9 +23102,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *
        CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
        LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21129,9 +23117,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21194,9 +23183,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env,
        scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
        LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21208,9 +23198,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdown ret_var = Shutdown_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21256,9 +23247,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1ma
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21270,9 +23262,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21344,11 +23337,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1ra
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -21376,9 +23372,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *
        fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
        fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
        LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21390,9 +23387,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21494,9 +23492,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21571,9 +23570,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1new(JNIE
        CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
        (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21585,9 +23585,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21640,9 +23641,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21710,9 +23712,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1cl
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21805,9 +23808,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1new(JNIEn
                htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
        }
        LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21819,9 +23823,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21903,9 +23908,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1new(JNIEnv *e
        CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
        LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21917,9 +23923,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21972,9 +23979,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1new(JNIEnv *env,
        CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
        (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
        LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21986,9 +23994,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *en
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22048,9 +24057,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
        (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
        LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22062,9 +24072,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22132,9 +24143,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(J
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22231,9 +24243,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1new
        CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
        (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22245,9 +24258,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22256,7 +24270,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clo
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetAddress_free(this_ptr_conv);
 }
@@ -22318,16 +24334,6 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEn
        return ret_arr;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = Result_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_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
        LDKu8slice ser_ref;
        ser_ref.datalen = (*env)->GetArrayLength(env, ser);
@@ -22350,9 +24356,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1g
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22455,7 +24462,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_
        int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                int64_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -22468,9 +24477,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22508,9 +24518,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1cont
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22537,9 +24548,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEn
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
        LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22551,9 +24563,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22572,9 +24585,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22707,9 +24721,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22804,9 +24819,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1c
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22842,9 +24858,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1new(JN
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22856,9 +24873,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23001,9 +25019,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23041,9 +25060,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1content
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23070,9 +25090,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
        LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23084,9 +25105,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23154,9 +25176,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1new(JNIE
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23168,9 +25191,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23284,9 +25308,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1new(JNIE
        }
        (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
        LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23298,9 +25323,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23369,9 +25395,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1new(J
        }
        (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23383,9 +25410,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23438,9 +25466,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1ne
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23452,9 +25481,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1cl
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23522,9 +25552,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1new(
        CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
        (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23536,9 +25567,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23547,7 +25579,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clon
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ErrorAction_free(this_ptr_conv);
 }
@@ -23636,19 +25670,24 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JN
        LDKLightningError this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
        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);
+       void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
+       CHECK_ACCESS(action_arg_ptr);
+       LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
        action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
        LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23660,9 +25699,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKLightningError ret_var = LightningError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23681,13 +25721,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_15_ref = 0;
                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;
+               ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
                if (ret_conv_15_var.is_owned) {
                        ret_conv_15_ref |= 1;
                }
@@ -23726,13 +25768,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_19_ref = 0;
                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;
+               ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
                if (ret_conv_19_var.is_owned) {
                        ret_conv_19_ref |= 1;
                }
@@ -23771,13 +25815,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
                if (ret_conv_16_var.is_owned) {
                        ret_conv_16_ref |= 1;
                }
@@ -23816,13 +25862,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_25_ref = 0;
                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;
+               ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
                if (ret_conv_25_var.is_owned) {
                        ret_conv_25_ref |= 1;
                }
@@ -23861,11 +25909,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1upda
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -23886,9 +25937,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1comm
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23980,9 +26032,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1new(JNIEn
        commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
        commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
        LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23994,9 +26047,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24005,14 +26059,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ChannelMessageHandler_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        RoutingMessageHandler_free(this_ptr_conv);
 }
@@ -24699,7 +26757,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        CustomMessageHandler_free(this_ptr_conv);
 }
@@ -24713,9 +26773,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(J
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
        LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24726,7 +26787,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24735,7 +26796,7 @@ 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;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24744,7 +26805,7 @@ 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;
-       LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
+       LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24753,7 +26814,7 @@ 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;
-       LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
+       LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24767,9 +26828,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(J
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
        LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24780,7 +26842,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24789,7 +26851,7 @@ 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;
-       LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24805,7 +26867,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -24813,7 +26876,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1han
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
        if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelMessageHandler_JCalls_cloned(&val_conv);
@@ -24825,7 +26890,8 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -24833,7 +26899,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1ha
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
        if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
@@ -24842,20 +26910,25 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1ha
 }
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1new(JNIEnv *env, jclass clz, int64_t chan_handler_arg, int64_t route_handler_arg) {
-       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
+       void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
+       CHECK_ACCESS(chan_handler_arg_ptr);
+       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
        if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
        }
-       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
+       void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
+       CHECK_ACCESS(route_handler_arg_ptr);
+       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
        if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
        }
        LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24863,15 +26936,19 @@ 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_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SocketDescriptor_free(this_ptr_conv);
 }
@@ -24900,9 +26977,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1conn
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
        LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24914,9 +26992,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24942,20 +27021,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *en
        CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
        (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
        unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
+       void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
+       CHECK_ACCESS(custom_message_handler_ptr);
+       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24967,13 +27051,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
-       jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
+       jobjectArray ret_arr = NULL;
+       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, 33);
                (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
                (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -24985,7 +27071,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_
        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);
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
@@ -24999,7 +27087,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
@@ -25013,7 +27103,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1write_1buffer_
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -25023,7 +27115,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1read_1event(JN
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
+       void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
+       if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
+       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = (*env)->GetArrayLength(env, data);
        data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
@@ -25044,7 +27138,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnec
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
 }
 
@@ -25058,6 +27154,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1n
        PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKPeerManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       PeerManager_disconnect_all_peers(&this_arg_conv);
+}
+
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -25265,9 +27368,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1new(JNIEnv
        CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
        (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
        LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25279,9 +27383,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25428,9 +27533,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1new(JNIE
        CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
        (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25442,9 +27548,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25607,7 +27714,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1t
        LDKHTLCOutputInCommitment this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
 }
@@ -25616,12 +27725,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1new
        LDKThirtyTwoBytes payment_hash_arg_ref;
        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);
+       void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
+       CHECK_ACCESS(transaction_output_index_arg_ptr);
+       LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25633,9 +27745,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25724,9 +27837,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25779,11 +27893,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -25804,11 +27921,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -25838,9 +27958,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
        funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25852,9 +27973,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25873,9 +27995,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25914,9 +28037,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
        pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25928,9 +28052,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransact
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25950,9 +28075,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25964,9 +28090,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameter
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26027,9 +28154,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26041,9 +28169,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26071,9 +28200,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionP
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26131,9 +28261,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26189,9 +28320,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction
        CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
        (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26257,9 +28389,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_
        CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
        (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26271,9 +28404,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26338,6 +28472,29 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEn
        ClosingTransaction_free(this_obj_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKClosingTransaction orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKClosingTransaction o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = ClosingTransaction_hash(&o_conv);
+       return ret_val;
+}
+
 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);
@@ -26352,9 +28509,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNI
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26366,9 +28524,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(J
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26484,9 +28643,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26551,9 +28711,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trus
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26599,9 +28760,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransactio
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26613,9 +28775,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransactio
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26698,9 +28861,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26712,9 +28876,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26726,9 +28891,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26740,9 +28906,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIE
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26779,9 +28946,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKInitFeatures ret_var = InitFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26790,9 +28958,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
        LDKInitFeatures ret_var = InitFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26809,9 +28978,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1un
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKNodeFeatures ret_var = NodeFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26820,9 +28990,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
        LDKNodeFeatures ret_var = NodeFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26839,9 +29010,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1un
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKChannelFeatures ret_var = ChannelFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26850,9 +29022,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIE
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
        LDKChannelFeatures ret_var = ChannelFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26869,9 +29042,10 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26880,9 +29054,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIE
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27017,9 +29192,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEn
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27060,9 +29236,25 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(
        script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
        LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       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_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKInvalidShutdownScript orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27096,9 +29288,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh
        (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
        unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27111,9 +29304,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(
        (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
        unsigned char (*script_hash_ref)[32] = &script_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27164,32 +29358,77 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compat
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
        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");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKType* orig_conv = (LDKType*)orig_ptr;
+       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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Type_free(this_ptr_conv);
 }
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Score_free(this_ptr_conv);
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKLockableScore this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockableScore_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
+       void* score_ptr = (void*)(((uint64_t)score) & ~1);
+       CHECK_ACCESS(score_ptr);
+       LDKScore score_conv = *(LDKScore*)(score_ptr);
+       if (score_conv.free == LDKScore_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKScore_JCalls_cloned(&score_conv);
+       }
+       LDKLockableScore ret_var = LockableScore_new(score_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_LockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKLockableScore obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = LockableScore_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_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKNodeId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -27202,9 +29441,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeId ret_var = NodeId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27216,9 +29456,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv
        CHECK((*env)->GetArrayLength(env, pubkey) == 33);
        (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
        LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27276,9 +29517,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27294,7 +29536,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetworkUpdate_free(this_ptr_conv);
 }
@@ -27348,7 +29592,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Eve
        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");
+       LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27360,37 +29604,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEn
        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;
-       if (ret_var.is_owned) {
-               ret_ref |= 1;
-       }
-       return ret_ref;
-}
-
-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);
-       val_conv = NetworkGraph_clone(&val_conv);
-       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);
-       network_graph_conv = NetworkGraph_clone(&network_graph_conv);
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       network_graph_conv.is_owned = false;
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -27399,15 +29619,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNI
                        LDKAccess_JCalls_cloned(&chain_access_conv.some);
                }
        }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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(network_graph_conv, chain_access_conv, logger_conv);
+       LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27418,7 +29641,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -27434,7 +29659,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Rou
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27443,7 +29668,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Mes
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -27529,7 +29754,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1h
        LDKDirectionalChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -27539,9 +29766,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27564,11 +29792,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27585,7 +29816,9 @@ 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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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));
@@ -27596,9 +29829,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1new
        last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
        last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27610,9 +29844,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27652,9 +29887,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27677,9 +29913,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27702,11 +29939,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27727,9 +29967,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27752,11 +29993,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27786,7 +30030,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sa
        LDKChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
 }
@@ -27796,11 +30042,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcem
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27837,16 +30086,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *en
        two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
        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);
+       void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
+       CHECK_ACCESS(capacity_sats_arg_ptr);
+       LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
        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);
        announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
        LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27858,9 +30110,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27927,9 +30180,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1new(JNIEnv *env, jclass clz, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
        LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27952,9 +30206,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28002,9 +30257,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28088,7 +30344,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1add
        int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                int64_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -28101,11 +30359,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28141,7 +30402,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(J
        int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
        for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
                int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
-               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               CHECK_ACCESS(addresses_arg_conv_12_ptr);
+               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
                addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
        }
        (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
@@ -28150,9 +30413,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(J
        announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
        announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28164,9 +30428,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28225,11 +30490,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbo
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28250,11 +30518,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -28292,9 +30563,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env,
        announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
        announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
        LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28306,9 +30578,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28362,9 +30635,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *e
        CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
        (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
        LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28376,9 +30650,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JN
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28416,7 +30691,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -28437,7 +30714,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -28536,9 +30815,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1featur
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28576,9 +30856,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1fea
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28639,9 +30920,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1new(JNIEnv *env,
        channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
        channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
        LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28653,9 +30935,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28714,17 +30997,20 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIE
        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);
+       jobjectArray ret_arr = NULL;
+       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_tArray ret_conv_12_arr = NULL;
+               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];
+                       uint64_t ret_conv_12_conv_10_ref = 0;
                        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;
+                       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;
                        }
@@ -28734,6 +31020,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIE
                FREE(ret_conv_12_var.data);
                (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -28771,7 +31058,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env,
        Route_set_paths(&this_ptr_conv, val_constr);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(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;
+       LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               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_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       Route_set_payee(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
        LDKCVec_CVec_RouteHopZZ paths_arg_constr;
        paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
        if (paths_arg_constr.datalen > 0)
@@ -28798,10 +31113,15 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jcl
                (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
                paths_arg_constr.data[m] = paths_arg_conv_12_constr;
        }
-       LDKRoute ret_var = Route_new(paths_arg_constr);
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28813,9 +31133,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, j
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoute ret_var = Route_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28878,6 +31199,367 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jc
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKRouteParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteParameters_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       RouteParameters_set_payee(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_value_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKRouteParameters orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteParameters_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_RouteParameters_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = RouteParameters_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKPayee this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Payee_free(this_obj_conv);
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPublicKey val_ref;
+       CHECK((*env)->GetArrayLength(env, val) == 33);
+       (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
+       Payee_set_pubkey(&this_ptr_conv, val_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               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_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKInvoiceFeatures val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = InvoiceFeatures_clone(&val_conv);
+       Payee_set_features(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
+       int64_tArray ret_arr = NULL;
+       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++) {
+               LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
+               CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               if (ret_conv_11_var.is_owned) {
+                       ret_conv_11_ref |= 1;
+               }
+               ret_arr_ptr[l] = ret_conv_11_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_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintZ val_constr;
+       val_constr.datalen = (*env)->GetArrayLength(env, val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               val_constr.data = NULL;
+       int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
+       for (size_t l = 0; l < val_constr.datalen; l++) {
+               int64_t val_conv_11 = val_vals[l];
+               LDKRouteHint val_conv_11_conv;
+               val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
+               val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
+               val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
+               val_constr.data[l] = val_conv_11_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
+       Payee_set_route_hints(&this_ptr_conv, val_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKPayee this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
+       val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
+       Payee_set_expiry_time(&this_ptr_conv, val_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
+       LDKPublicKey pubkey_arg_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
+       LDKInvoiceFeatures 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 = InvoiceFeatures_clone(&features_arg_conv);
+       LDKCVec_RouteHintZ route_hints_arg_constr;
+       route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
+       if (route_hints_arg_constr.datalen > 0)
+               route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               route_hints_arg_constr.data = NULL;
+       int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
+       for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
+               int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
+               LDKRouteHint route_hints_arg_conv_11_conv;
+               route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
+               route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
+               route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
+               route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
+       void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
+       CHECK_ACCESS(expiry_time_arg_ptr);
+       LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
+       expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
+       LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKPayee orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKPayee ret_var = Payee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = Payee_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKPayee a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKPayee b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = Payee_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKPayee obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Payee_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_Payee_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = Payee_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_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
+       LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK((*env)->GetArrayLength(env, pubkey) == 33);
+       (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
+       LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKRouteHint this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -28885,14 +31567,90 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, j
        RouteHint_free(this_obj_conv);
 }
 
+JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
+       for (size_t o = 0; o < ret_var.datalen; o++) {
+               LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
+               CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               if (ret_conv_14_var.is_owned) {
+                       ret_conv_14_ref |= 1;
+               }
+               ret_arr_ptr[o] = ret_conv_14_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_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ val_constr;
+       val_constr.datalen = (*env)->GetArrayLength(env, val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               val_constr.data = NULL;
+       int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
+       for (size_t o = 0; o < val_constr.datalen; o++) {
+               int64_t val_conv_14 = val_vals[o];
+               LDKRouteHintHop val_conv_14_conv;
+               val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
+               val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
+               val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
+               val_constr.data[o] = val_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
+       RouteHint_set_a(&this_ptr_conv, val_constr);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
+       LDKCVec_RouteHintHopZ a_arg_constr;
+       a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
+       if (a_arg_constr.datalen > 0)
+               a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               a_arg_constr.data = NULL;
+       int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
+       for (size_t o = 0; o < a_arg_constr.datalen; o++) {
+               int64_t a_arg_conv_14 = a_arg_vals[o];
+               LDKRouteHintHop a_arg_conv_14_conv;
+               a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
+               a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
+               a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
+               a_arg_constr.data[o] = a_arg_conv_14_conv;
+       }
+       (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
+       LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
+       uint64_t ret_ref = 0;
+       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.
+       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_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKRouteHint orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -28918,6 +31676,27 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env,
        return ret_val;
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteHint obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHint_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_RouteHint_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = RouteHint_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
 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));
@@ -28964,9 +31743,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNI
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29013,7 +31793,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minim
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
 }
@@ -29032,7 +31814,9 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maxim
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -29045,14 +31829,19 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new(JNIEnv *e
        fees_arg_conv.inner = (void*)(fees_arg & (~1));
        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);
+       void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
        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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29064,9 +31853,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29092,77 +31882,37 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *e
        return ret_val;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, 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, int64_t scorer) {
-       LDKPublicKey our_node_pubkey_ref;
-       CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
-       (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
-       LDKNetworkGraph network_conv;
-       network_conv.inner = (void*)(network & (~1));
-       network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK((*env)->GetArrayLength(env, payee) == 33);
-       (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
-       LDKCVec_ChannelDetailsZ first_hops_constr;
-       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
-       if (first_hops != NULL) {
-               first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
-               if (first_hops_constr.datalen > 0)
-                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-               else
-                       first_hops_constr.data = NULL;
-               int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
-               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
-                       int64_t first_hops_conv_16 = first_hops_vals[q];
-                       LDKChannelDetails first_hops_conv_16_conv;
-                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
-                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
-                       first_hops_constr.data[q] = first_hops_conv_16_conv;
-               }
-               (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
-               first_hops_ptr = &first_hops_constr;
-       }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               int64_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
-       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);
-       }
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
-       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
-       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKRouteHintHop obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHintHop_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_RouteHintHop_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = RouteHintHop_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_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger, int64_t scorer) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
        LDKPublicKey our_node_pubkey_ref;
        CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
        (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
        LDKNetworkGraph network_conv;
        network_conv.inner = (void*)(network & (~1));
        network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK((*env)->GetArrayLength(env, payee) == 33);
-       (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
-       LDKInvoiceFeatures payee_features_conv;
-       payee_features_conv.inner = (void*)(payee_features & (~1));
-       payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
-       payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
        LDKCVec_ChannelDetailsZ first_hops_constr;
        LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
        if (first_hops != NULL) {
@@ -29182,30 +31932,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jcl
                (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
                first_hops_ptr = &first_hops_constr;
        }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               int64_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
+       *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
        if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
        return (uint64_t)ret_conv;
 }
@@ -29217,11 +31955,101 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jcla
        Scorer_free(this_obj_conv);
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat) {
-       LDKScorer ret_var = Scorer_new(base_penalty_msat);
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKScoringParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ScoringParameters_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
+       LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKScoringParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = ScoringParameters_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_ScoringParameters_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = ScoringParameters_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_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
+       LDKScoringParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = (params & 1) || (params == 0);
+       // Warning: we need a move here but no clone is available for LDKScoringParameters
+       LDKScorer ret_var = Scorer_new(params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29230,9 +32058,22 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jc
 
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
        LDKScorer ret_var = Scorer_default();
+       uint64_t ret_ref = 0;
+       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.
+       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_ScoringParameters_1default(JNIEnv *env, jclass clz) {
+       LDKScoringParameters ret_var = ScoringParameters_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29243,11 +32084,32 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *e
        LDKScorer this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
+       LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
        *ret_ret = Scorer_as_Score(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
+       LDKScorer obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Scorer_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_Scorer_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = Scorer_read(ser_ref);
+       (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
+       return (uint64_t)ret_conv;
+}
+
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
        LDKFilesystemPersister this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -29258,9 +32120,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIE
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
        LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
        LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29291,7 +32154,9 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1
        LDKFilesystemPersister this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
@@ -29305,7 +32170,7 @@ 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_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
+       LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
        *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -29319,18 +32184,24 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        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 net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
-       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
        if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
        }
-       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
        if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKEventHandler_JCalls_cloned(&event_handler_conv);
@@ -29347,15 +32218,18 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(
        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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
        }
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29409,9 +32283,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoice ret_var = Invoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29441,9 +32316,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29462,9 +32338,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEn
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29498,9 +32375,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29519,9 +32397,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29555,9 +32434,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29587,9 +32467,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JN
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29691,9 +32572,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env,
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSha256 ret_var = Sha256_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29731,9 +32613,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDescription ret_var = Description_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29766,14 +32649,49 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env,
        PayeePubKey_free(this_obj_conv);
 }
 
+JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKPayeePubKey this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
+       return ret_arr;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
+       LDKPayeePubKey this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPublicKey val_ref;
+       CHECK((*env)->GetArrayLength(env, val) == 33);
+       (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
+       PayeePubKey_set_a(&this_ptr_conv, val_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
+       LDKPublicKey a_arg_ref;
+       CHECK((*env)->GetArrayLength(env, a_arg) == 33);
+       (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
+       LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       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_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
        LDKPayeePubKey orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29811,9 +32729,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *e
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29846,14 +32765,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEn
        MinFinalCltvExpiry_free(this_obj_conv);
 }
 
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
+       LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29881,7 +32828,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNI
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Fallback_free(this_ptr_conv);
 }
@@ -29951,9 +32900,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNI
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -29983,9 +32933,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30026,9 +32977,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30049,9 +33001,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30089,11 +33042,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(J
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_payment_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30103,11 +33059,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNI
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDescription ret_var = RawInvoice_description(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30117,11 +33076,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30131,11 +33093,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1ha
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_description_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30145,11 +33110,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JN
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKExpiryTime ret_var = RawInvoice_expiry_time(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30159,11 +33127,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1clt
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30182,11 +33153,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = RawInvoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30196,13 +33170,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1r
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
@@ -30265,9 +33241,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = Invoice_clone(&this_arg_conv);
        LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30324,7 +33301,7 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secre
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
-       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
+       (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
        return ret_arr;
 }
 
@@ -30333,11 +33310,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *e
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = Invoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -30359,6 +33339,14 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEn
        return ret_val;
 }
 
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKInvoice this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       jboolean ret_val = Invoice_is_expired(&this_arg_conv);
+       return ret_val;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -30372,13 +33360,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1rout
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
        int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
        for (size_t o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
@@ -30394,13 +33384,15 @@ JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
-       int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
+       int64_tArray ret_arr = NULL;
+       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++) {
                LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
                CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
                if (ret_conv_11_var.is_owned) {
                        ret_conv_11_ref |= 1;
                }
@@ -30419,12 +33411,12 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *en
        return ret_conv;
 }
 
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
+       *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -30491,9 +33483,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(J
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = PrivateRoute_clone(&this_arg_conv);
        LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -30614,7 +33607,9 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIE
 
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SignOrCreationError_free(this_ptr_conv);
 }
@@ -30657,17 +33652,252 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1st
        return ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKInvoicePayer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       InvoicePayer_free(this_obj_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Payer_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Router_free(this_ptr_conv);
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKRetryAttempts this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RetryAttempts_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RetryAttempts_set_a(&this_ptr_conv, val);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
+       LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       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_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKRetryAttempts orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
+       LDKRetryAttempts a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKRetryAttempts b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
+       LDKRetryAttempts o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_hash(&o_conv);
+       return ret_val;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       PaymentError_free(this_ptr_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
+       LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
+       LDKStr a_conv = java_to_owned_str(env, a);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_invoice(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
+       LDKLightningError a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = (a & 1) || (a == 0);
+       a_conv = LightningError_clone(&a_conv);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_routing(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
+       a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_sending(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
+       void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
+       CHECK_ACCESS(payer_ptr);
+       LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
+       if (payer_conv.free == LDKPayer_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKPayer_JCalls_cloned(&payer_conv);
+       }
+       void* router_ptr = (void*)(((uint64_t)router) & ~1);
+       CHECK_ACCESS(router_ptr);
+       LDKRouter router_conv = *(LDKRouter*)(router_ptr);
+       if (router_conv.free == LDKRouter_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKRouter_JCalls_cloned(&router_conv);
+       }
+       LDKLockableScore scorer_conv;
+       scorer_conv.inner = (void*)(scorer & (~1));
+       scorer_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       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);
+       }
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
+       if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
+               // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
+               LDKEventHandler_JCalls_cloned(&event_handler_conv);
+       }
+       LDKRetryAttempts retry_attempts_conv;
+       retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
+       retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
+       retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
+       LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
+       return (uint64_t)ret_conv;
+}
+
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       unsigned char payment_hash_arr[32];
+       CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
+       (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
+       unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
+       InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKInvoicePayer 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 = InvoicePayer_as_EventHandler(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description) {
        LDKChannelManager channelmanager_conv;
        channelmanager_conv.inner = (void*)(channelmanager & (~1));
        channelmanager_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
                // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
                LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
        }
        LDKCurrency network_conv = LDKCurrency_from_java(env, network);
-       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
+       void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
+       CHECK_ACCESS(amt_msat_ptr);
+       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
        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");
@@ -30675,6 +33905,53 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1chan
        return (uint64_t)ret_conv;
 }
 
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
+       LDKDefaultRouter this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       DefaultRouter_free(this_obj_conv);
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
+       LDKNetworkGraph network_graph_conv;
+       network_graph_conv.inner = (void*)(network_graph & (~1));
+       network_graph_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       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);
+       }
+       LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
+       uint64_t ret_ref = 0;
+       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.
+       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_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
+       LDKDefaultRouter this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
+JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(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;
+       LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
        LDKStr s_conv = java_to_owned_str(env, s);
        LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
index 82234decfda08c3a8f950f6b3054fc3596b98541..bef74b1b3f4c264f36a2dc4cbe083ef109a1d0f7 100644 (file)
@@ -631,6 +631,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteParametersDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteParametersDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteParametersDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCVec_RouteHintZ_new
+ * Signature: ([J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new
+  (JNIEnv *, jclass, jlongArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    LDKCOption_u64Z_ref_from_ptr
@@ -641,18 +673,90 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    LDKCVec_ChannelDetailsZ_new
+ * Method:    LDKCResult_PayeeDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_PayeeDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_PayeeDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCVec_RouteHintHopZ_new
  * Signature: ([J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintHopZ_1new
   (JNIEnv *, jclass, jlongArray);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    LDKCVec_RouteHintZ_new
+ * Method:    LDKCResult_RouteHintDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteHintDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteHintDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteHintHopDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteHintHopDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_RouteHintHopDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCVec_ChannelDetailsZ_new
  * Signature: ([J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new
   (JNIEnv *, jclass, jlongArray);
 
 /*
@@ -703,14 +807,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_usizeTransactionZ_new
- * Signature: (J[B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new
-  (JNIEnv *, jclass, jlong, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_usizeTransactionZ_get_a
@@ -935,6 +1031,54 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDe
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScoringParametersDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScoringParametersDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScoringParametersDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScorerDecodeErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScorerDecodeErrorZ_get_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_ScorerDecodeErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok
@@ -1031,14 +1175,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok
 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
- * Signature: ([B[[B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new
-  (JNIEnv *, jclass, jbyteArray, jobjectArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_SignatureCVec_SignatureZZ_get_a
@@ -1375,14 +1511,6 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionN
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_BlockHashChannelMonitorZ_new
- * Signature: ([BJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_BlockHashChannelMonitorZ_get_a
@@ -1431,30 +1559,6 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tupl
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_PaymentIdDecodeErrorZ_result_ok
- * Signature: (J)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1result_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_PaymentIdDecodeErrorZ_get_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_PaymentIdDecodeErrorZ_get_err
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdDecodeErrorZ_1get_1err
-  (JNIEnv *, jclass, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    LDKCOption_u16Z_ref_from_ptr
@@ -1554,9 +1658,9 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPayme
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    LDKCResult_PaymentIdPaymentSendFailureZ_get_ok
- * Signature: (J)J
+ * Signature: (J)[B
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok
   (JNIEnv *, jclass, jlong);
 
 /*
@@ -1591,14 +1695,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFai
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_PaymentHashPaymentIdZ_new
- * Signature: ([BJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentIdZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_PaymentHashPaymentIdZ_get_a
@@ -1610,9 +1706,9 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaym
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_PaymentHashPaymentIdZ_get_b
- * Signature: (J)J
+ * Signature: (J)[B
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b
   (JNIEnv *, jclass, jlong);
 
 /*
@@ -1655,14 +1751,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1p
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new
   (JNIEnv *, jclass, jlongArray);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_PaymentHashPaymentSecretZ_new
- * Signature: ([B[B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new
-  (JNIEnv *, jclass, jbyteArray, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_PaymentHashPaymentSecretZ_get_a
@@ -1847,14 +1935,6 @@ JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1get_1est_1sat_1p
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new
   (JNIEnv *, jclass, jobject);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_BlockHashChannelManagerZ_new
- * Signature: ([BJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_BlockHashChannelManagerZ_get_a
@@ -2007,6 +2087,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDec
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKPaymentError_ref_from_ptr
+ * Signature: (J)Lorg/ldk/impl/bindings/LDKPaymentError;
+ */
+JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_PaymentIdPaymentErrorZ_result_ok
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1result_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_PaymentIdPaymentErrorZ_get_ok
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKCResult_PaymentIdPaymentErrorZ_get_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    LDKCResult_SiPrefixNoneZ_result_ok
@@ -2079,14 +2191,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceN
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new
- * Signature: (J[BJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1new
-  (JNIEnv *, jclass, jlong, jbyteArray, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a
@@ -2383,14 +2487,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateE
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_OutPointScriptZ_new
- * Signature: (J[B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new
-  (JNIEnv *, jclass, jlong, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_OutPointScriptZ_get_a
@@ -2407,14 +2503,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get
 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_u32ScriptZ_new
- * Signature: (I[B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new
-  (JNIEnv *, jclass, jint, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_u32ScriptZ_get_a
@@ -2439,14 +2527,6 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new
   (JNIEnv *, jclass, jlongArray);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new
- * Signature: ([B[J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlongArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a
@@ -2503,14 +2583,6 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new
   (JNIEnv *, jclass, jlongArray);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_u32TxOutZ_new
- * Signature: (IJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new
-  (JNIEnv *, jclass, jint, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_u32TxOutZ_get_a
@@ -2535,14 +2607,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new
   (JNIEnv *, jclass, jlongArray);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new
- * Signature: ([B[J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlongArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a
@@ -2631,14 +2695,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningError
 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:    C2Tuple_PublicKeyTypeZ_get_a
@@ -2687,14 +2743,6 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningE
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new
- * Signature: (JJJ)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new
-  (JNIEnv *, jclass, jlong, jlong, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a
@@ -3017,66 +3065,18 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddres
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_NetAddressu8Z_result_ok
+ * Method:    LDKCResult_NetAddressDecodeErrorZ_result_ok
  * Signature: (J)Z
  */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_NetAddressu8Z_get_ok
+ * Method:    LDKCResult_NetAddressDecodeErrorZ_get_ok
  * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_NetAddressu8Z_get_err
- * Signature: (J)B
- */
-JNIEXPORT jbyte JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok
- * Signature: (J)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_NetAddressDecodeErrorZ_result_ok
- * Signature: (J)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    LDKCResult_NetAddressDecodeErrorZ_get_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok
   (JNIEnv *, jclass, jlong);
 
 /*
@@ -4106,18 +4106,18 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Persist_persist_new_channel
- * Signature: (JJJ)J
+ * Signature: (JJJJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel
-  (JNIEnv *, jclass, jlong, jlong, jlong);
+  (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Persist_update_persisted_channel
- * Signature: (JJJJ)J
+ * Signature: (JJJJJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel
-  (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
+  (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -4482,10 +4482,26 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKScore_1new
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Score_channel_penalty_msat
- * Signature: (JJ)J
+ * Signature: (JJJJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat
-  (JNIEnv *, jclass, jlong, jlong);
+  (JNIEnv *, jclass, jlong, jlong, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Score_payment_path_failed
+ * Signature: (J[JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed
+  (JNIEnv *, jclass, jlong, jlongArray, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Score_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Score_1write
+  (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -4511,6 +4527,62 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1pers
 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKPayer_new
+ * Signature: (Lorg/ldk/impl/bindings/LDKPayer;)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new
+  (JNIEnv *, jclass, jobject);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payer_node_id
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payer_first_hops
+ * Signature: (J)[J
+ */
+JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payer_send_payment
+ * Signature: (JJ[B[B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment
+  (JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payer_retry_payment
+ * Signature: (JJ[B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment
+  (JNIEnv *, jclass, jlong, jlong, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    LDKRouter_new
+ * Signature: (Lorg/ldk/impl/bindings/LDKRouter;)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new
+  (JNIEnv *, jclass, jobject);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Router_find_route
+ * Signature: (J[BJ[JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Router_1find_1route
+  (JNIEnv *, jclass, jlong, jbyteArray, jlong, jlongArray, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    _ldk_get_compiled_version
@@ -5087,6 +5159,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvali
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ShutdownScriptInvalidShutdownScriptZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_NoneErrorZ_ok
@@ -5199,6 +5279,46 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1fr
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteParametersDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteParametersDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteParametersDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteParametersDecodeErrorZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CVec_RouteHintZ_free
+ * Signature: ([J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free
+  (JNIEnv *, jclass, jlongArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    COption_u64Z_some
@@ -5233,18 +5353,114 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    CVec_ChannelDetailsZ_free
+ * Method:    CResult_PayeeDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PayeeDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PayeeDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PayeeDecodeErrorZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CVec_RouteHintHopZ_free
  * Signature: ([J)V
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free
   (JNIEnv *, jclass, jlongArray);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    CVec_RouteHintZ_free
+ * Method:    CResult_RouteHintDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintDecodeErrorZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintHopDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintHopDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintHopDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_RouteHintHopDecodeErrorZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CVec_ChannelDetailsZ_free
  * Signature: ([J)V
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free
   (JNIEnv *, jclass, jlongArray);
 
 /*
@@ -5567,6 +5783,54 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecod
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScoringParametersDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScoringParametersDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScoringParametersDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScorerDecodeErrorZ_ok
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScorerDecodeErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_ScorerDecodeErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok
@@ -6033,40 +6297,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Block
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    CResult_PaymentIdDecodeErrorZ_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_PaymentIdDecodeErrorZ_err
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1err
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_PaymentIdDecodeErrorZ_free
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1free
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_PaymentIdDecodeErrorZ_clone
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdDecodeErrorZ_1clone
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    COption_u16Z_some
- * Signature: (S)J
+ * Method:    COption_u16Z_some
+ * Signature: (S)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some
   (JNIEnv *, jclass, jshort);
@@ -6178,10 +6410,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clo
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_PaymentIdPaymentSendFailureZ_ok
- * Signature: (J)J
+ * Signature: ([B)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok
-  (JNIEnv *, jclass, jlong);
+  (JNIEnv *, jclass, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -6250,10 +6482,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentId
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    C2Tuple_PaymentHashPaymentIdZ_new
- * Signature: ([BJ)J
+ * Signature: ([B[B)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new
-  (JNIEnv *, jclass, jbyteArray, jlong);
+  (JNIEnv *, jclass, jbyteArray, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -6535,6 +6767,38 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeE
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PaymentIdPaymentErrorZ_ok
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PaymentIdPaymentErrorZ_err
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PaymentIdPaymentErrorZ_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    CResult_PaymentIdPaymentErrorZ_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_SiPrefixNoneZ_ok
@@ -7743,70 +8007,6 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1f
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_NetAddressu8Z_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_NetAddressu8Z_err
- * Signature: (B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err
-  (JNIEnv *, jclass, jbyte);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_NetAddressu8Z_free
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_NetAddressu8Z_clone
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_CResult_NetAddressu8ZDecodeErrorZ_ok
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_CResult_NetAddressu8ZDecodeErrorZ_err
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_CResult_NetAddressu8ZDecodeErrorZ_free
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    CResult_CResult_NetAddressu8ZDecodeErrorZ_clone
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone
-  (JNIEnv *, jclass, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    CResult_NetAddressDecodeErrorZ_ok
@@ -9130,18 +9330,18 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Event_payment_sent
- * Signature: ([B[B)J
+ * Signature: ([B[B[BJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent
-  (JNIEnv *, jclass, jbyteArray, jbyteArray);
+  (JNIEnv *, jclass, jbyteArray, jbyteArray, jbyteArray, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Event_payment_path_failed
- * Signature: ([BZJZ[JJ)J
+ * Signature: ([B[BZJZ[JJJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed
-  (JNIEnv *, jclass, jbyteArray, jboolean, jlong, jboolean, jlongArray, jlong);
+  (JNIEnv *, jclass, jbyteArray, jbyteArray, jboolean, jlong, jboolean, jlongArray, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -10319,6 +10519,38 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateId_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateId_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateId_hash
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateId_eq
+ * Signature: (JJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq
+  (JNIEnv *, jclass, jlong, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Persist_free
@@ -10375,6 +10607,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor
 JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    ChainMonitor_channel_monitor_updated
+ * Signature: (JJJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated
+  (JNIEnv *, jclass, jlong, jlong, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ChainMonitor_as_Listen
@@ -10463,6 +10703,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateError_get_a
+ * Signature: (J)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateError_set_a
+ * Signature: (JLjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a
+  (JNIEnv *, jclass, jlong, jstring);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorUpdateError_new
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new
+  (JNIEnv *, jclass, jstring);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    MonitorUpdateError_clone
@@ -10503,6 +10767,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorEvent_update_completed
+ * Signature: (JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorEvent_update_failed
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MonitorEvent_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    HTLCUpdate_free
@@ -11431,54 +11719,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1spend_1spendable
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_free
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentId_1free
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_hash
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentId_1hash
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_clone
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentId_1clone
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_eq
- * Signature: (JJ)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentId_1eq
-  (JNIEnv *, jclass, jlong, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_write
- * Signature: (J)[B
- */
-JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PaymentId_1write
-  (JNIEnv *, jclass, jlong);
-
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    PaymentId_read
- * Signature: ([B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentId_1read
-  (JNIEnv *, jclass, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ChannelManager_free
@@ -12010,10 +12250,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1fail
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    PaymentSendFailure_partial_failure
- * Signature: ([J)J
+ * Signature: ([JJ[B)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure
-  (JNIEnv *, jclass, jlongArray);
+  (JNIEnv *, jclass, jlongArray, jlong, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -12098,10 +12338,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ChannelManager_retry_payment
- * Signature: (JJJ)J
+ * Signature: (JJ[B)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment
-  (JNIEnv *, jclass, jlong, jlong, jlong);
+  (JNIEnv *, jclass, jlong, jlong, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -12167,14 +12407,6 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1fun
 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    ChannelManager_channel_monitor_updated
- * Signature: (JJJ)V
- */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1monitor_1updated
-  (JNIEnv *, jclass, jlong, jlong, jlong);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ChannelManager_create_inbound_payment
@@ -14271,14 +14503,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v3
 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write
   (JNIEnv *, jclass, jlong);
 
-/*
- * Class:     org_ldk_impl_bindings
- * Method:    Result_read
- * Signature: ([B)J
- */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Result_1read
-  (JNIEnv *, jclass, jbyteArray);
-
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    NetAddress_read
@@ -16255,6 +16479,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnec
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1node_1id
   (JNIEnv *, jclass, jlong, jbyteArray, jboolean);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PeerManager_disconnect_all_peers
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    PeerManager_timer_tick_occurred
@@ -17143,6 +17375,22 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransacti
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    ClosingTransaction_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    ClosingTransaction_hash
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ClosingTransaction_new
@@ -17687,6 +17935,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1sc
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new
   (JNIEnv *, jclass, jbyteArray);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvalidShutdownScript_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    ShutdownScript_write
@@ -17785,27 +18041,51 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    NodeId_free
+ * Method:    LockableScore_free
  * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    NodeId_clone
+ * Method:    LockableScore_new
  * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeId_1clone
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LockableScore_1new
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    NodeId_from_pubkey
- * Signature: ([B)J
+ * Method:    LockableScore_write
+ * Signature: (J)[B
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey
-  (JNIEnv *, jclass, jbyteArray);
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_LockableScore_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    NodeId_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    NodeId_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeId_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    NodeId_from_pubkey
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey
+  (JNIEnv *, jclass, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -17927,22 +18207,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1Event
 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_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
@@ -18855,13 +19119,29 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths
   (JNIEnv *, jclass, jlong, jobjectArray);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Route_get_payee
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Route_set_payee
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee
+  (JNIEnv *, jclass, jlong, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Route_new
- * Signature: ([[J)J
+ * Signature: ([[JJ)J
  */
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1new
-  (JNIEnv *, jclass, jobjectArray);
+  (JNIEnv *, jclass, jobjectArray, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -18919,6 +19199,230 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Route_1write
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read
   (JNIEnv *, jclass, jbyteArray);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_get_payee
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_set_payee
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_get_final_value_msat
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_set_final_value_msat
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_get_final_cltv_expiry_delta
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_set_final_cltv_expiry_delta
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta
+  (JNIEnv *, jclass, jlong, jint);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_new
+ * Signature: (JJI)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new
+  (JNIEnv *, jclass, jlong, jlong, jint);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteParameters_read
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_get_pubkey
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_set_pubkey
+ * Signature: (J[B)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey
+  (JNIEnv *, jclass, jlong, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_get_features
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_set_features
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_get_route_hints
+ * Signature: (J)[J
+ */
+JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_set_route_hints
+ * Signature: (J[J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints
+  (JNIEnv *, jclass, jlong, jlongArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_get_expiry_time
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_set_expiry_time
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_new
+ * Signature: ([BJ[JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1new
+  (JNIEnv *, jclass, jbyteArray, jlong, jlongArray, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_hash
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1hash
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_eq
+ * Signature: (JJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Payee_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_read
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1read
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_from_node_id
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id
+  (JNIEnv *, jclass, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payee_for_keysend
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend
+  (JNIEnv *, jclass, jbyteArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    RouteHint_free
@@ -18927,6 +19431,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Route_1read
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHint_get_a
+ * Signature: (J)[J
+ */
+JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHint_set_a
+ * Signature: (J[J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a
+  (JNIEnv *, jclass, jlong, jlongArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHint_new
+ * Signature: ([J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1new
+  (JNIEnv *, jclass, jlongArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    RouteHint_clone
@@ -18951,6 +19479,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash
 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq
   (JNIEnv *, jclass, jlong, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHint_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHint_read
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1read
+  (JNIEnv *, jclass, jbyteArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    RouteHintHop_free
@@ -19009,107 +19553,195 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_get_cltv_expiry_delta
- * Signature: (J)S
+ * Method:    RouteHintHop_get_cltv_expiry_delta
+ * Signature: (J)S
+ */
+JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_set_cltv_expiry_delta
+ * Signature: (JS)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta
+  (JNIEnv *, jclass, jlong, jshort);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_get_htlc_minimum_msat
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_set_htlc_minimum_msat
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_get_htlc_maximum_msat
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_set_htlc_maximum_msat
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_new
+ * Signature: ([BJJSJJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new
+  (JNIEnv *, jclass, jbyteArray, jlong, jlong, jshort, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_hash
+ * Signature: (J)J
+ */
+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:    RouteHintHop_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RouteHintHop_read
+ * Signature: ([B)J
  */
-JNIEXPORT jshort JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta
-  (JNIEnv *, jclass, jlong);
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read
+  (JNIEnv *, jclass, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_set_cltv_expiry_delta
- * Signature: (JS)V
+ * Method:    find_route
+ * Signature: ([BJJ[JJJ)J
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta
-  (JNIEnv *, jclass, jlong, jshort);
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_find_1route
+  (JNIEnv *, jclass, jbyteArray, jlong, jlong, jlongArray, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_get_htlc_minimum_msat
- * Signature: (J)J
+ * Method:    Scorer_free
+ * Signature: (J)V
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_set_htlc_minimum_msat
- * Signature: (JJ)V
+ * Method:    ScoringParameters_free
+ * Signature: (J)V
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat
-  (JNIEnv *, jclass, jlong, jlong);
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free
+  (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_get_htlc_maximum_msat
+ * Method:    ScoringParameters_get_base_penalty_msat
  * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_set_htlc_maximum_msat
+ * Method:    ScoringParameters_set_base_penalty_msat
  * Signature: (JJ)V
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat
   (JNIEnv *, jclass, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_new
- * Signature: ([BJJSJJ)J
+ * Method:    ScoringParameters_get_failure_penalty_msat
+ * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1new
-  (JNIEnv *, jclass, jbyteArray, jlong, jlong, jshort, jlong, jlong);
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat
+  (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_clone
- * Signature: (J)J
+ * Method:    ScoringParameters_set_failure_penalty_msat
+ * Signature: (JJ)V
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone
-  (JNIEnv *, jclass, jlong);
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat
+  (JNIEnv *, jclass, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_hash
+ * Method:    ScoringParameters_get_failure_penalty_half_life
  * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life
   (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    RouteHintHop_eq
- * Signature: (JJ)Z
+ * Method:    ScoringParameters_set_failure_penalty_half_life
+ * Signature: (JJ)V
  */
-JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life
   (JNIEnv *, jclass, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    get_keysend_route
- * Signature: ([BJ[B[J[JJIJJ)J
+ * Method:    ScoringParameters_new
+ * Signature: (JJJ)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1keysend_1route
-  (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlongArray, jlongArray, jlong, jint, jlong, jlong);
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new
+  (JNIEnv *, jclass, jlong, jlong, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    get_route
- * Signature: ([BJ[BJ[J[JJIJJ)J
+ * Method:    ScoringParameters_write
+ * Signature: (J)[B
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route
-  (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlong, jlongArray, jlongArray, jlong, jint, jlong, jlong);
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write
+  (JNIEnv *, jclass, jlong);
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    Scorer_free
- * Signature: (J)V
+ * Method:    ScoringParameters_read
+ * Signature: ([B)J
  */
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free
-  (JNIEnv *, jclass, jlong);
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read
+  (JNIEnv *, jclass, jbyteArray);
 
 /*
  * Class:     org_ldk_impl_bindings
@@ -19127,6 +19759,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Scorer_1new
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Scorer_1default
   (JNIEnv *, jclass);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    ScoringParameters_default
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default
+  (JNIEnv *, jclass);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Scorer_as_Score
@@ -19135,6 +19775,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Scorer_1default
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Scorer_write
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Scorer_read
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Scorer_1read
+  (JNIEnv *, jclass, jbyteArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    FilesystemPersister_free
@@ -19575,6 +20231,30 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PayeePubKey_get_a
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PayeePubKey_set_a
+ * Signature: (J[B)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a
+  (JNIEnv *, jclass, jlong, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PayeePubKey_new
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new
+  (JNIEnv *, jclass, jbyteArray);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    PayeePubKey_clone
@@ -19639,6 +20319,30 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq
 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MinFinalCltvExpiry_get_a
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MinFinalCltvExpiry_set_a
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    MinFinalCltvExpiry_new
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    MinFinalCltvExpiry_clone
@@ -20031,6 +20735,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Invoice_is_expired
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    Invoice_min_final_cltv_expiry
@@ -20065,10 +20777,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_Invoice_1currency
 
 /*
  * Class:     org_ldk_impl_bindings
- * Method:    Invoice_amount_pico_btc
+ * Method:    Invoice_amount_milli_satoshis
  * Signature: (J)J
  */
-JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis
   (JNIEnv *, jclass, jlong);
 
 /*
@@ -20343,6 +21055,166 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq
 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str
   (JNIEnv *, jclass, jlong);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Payer_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    Router_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_get_a
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_set_a
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_new
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_eq
+ * Signature: (JJ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    RetryAttempts_hash
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PaymentError_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PaymentError_clone
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PaymentError_invoice
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice
+  (JNIEnv *, jclass, jstring);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PaymentError_routing
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    PaymentError_sending
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_new
+ * Signature: (JJJJJJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new
+  (JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_pay_invoice
+ * Signature: (JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_pay_zero_value_invoice
+ * Signature: (JJJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice
+  (JNIEnv *, jclass, jlong, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_remove_cached_payment
+ * Signature: (J[B)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment
+  (JNIEnv *, jclass, jlong, jbyteArray);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    InvoicePayer_as_EventHandler
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    create_invoice_from_channelmanager
@@ -20351,6 +21223,38 @@ JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1st
 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager
   (JNIEnv *, jclass, jlong, jlong, jobject, jlong, jstring);
 
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    DefaultRouter_free
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    DefaultRouter_new
+ * Signature: (JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new
+  (JNIEnv *, jclass, jlong, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    DefaultRouter_as_Router
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_ldk_impl_bindings
+ * Method:    ChannelManager_as_Payer
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer
+  (JNIEnv *, jclass, jlong);
+
 /*
  * Class:     org_ldk_impl_bindings
  * Method:    SiPrefix_from_str
diff --git a/src/main/jni/org_ldk_impl_bindings_LDKPaymentError.h b/src/main/jni/org_ldk_impl_bindings_LDKPaymentError.h
new file mode 100644 (file)
index 0000000..f8fdf4a
--- /dev/null
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_ldk_impl_bindings_LDKPaymentError */
+
+#ifndef _Included_org_ldk_impl_bindings_LDKPaymentError
+#define _Included_org_ldk_impl_bindings_LDKPaymentError
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     org_ldk_impl_bindings_LDKPaymentError
+ * Method:    init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init
+  (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index 261902b7f059197387feae6e9b6b78fbfdcac770..a123b6e31b270cfcb1820b8adb62425ecf34e5bf 100644 (file)
@@ -26,8 +26,9 @@ class HumanObjectPeerTestInstance {
     private final boolean use_filter;
     private final boolean use_ignore_handler;
     private final boolean use_chan_manager_constructor;
+    private final boolean use_invoice_payer;
 
-    HumanObjectPeerTestInstance(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean use_nio_peer_handler, boolean use_filter, boolean use_ignore_handler, boolean use_chan_manager_constructor) {
+    HumanObjectPeerTestInstance(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean use_nio_peer_handler, boolean use_filter, boolean use_ignore_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) {
         this.nice_close = nice_close;
         this.use_km_wrapper = use_km_wrapper;
         this.use_manual_watch = use_manual_watch;
@@ -37,6 +38,7 @@ class HumanObjectPeerTestInstance {
         this.use_filter = use_filter;
         this.use_ignore_handler = use_ignore_handler;
         this.use_chan_manager_constructor = use_chan_manager_constructor;
+        this.use_invoice_payer = use_invoice_payer;
     }
 
     class Peer {
@@ -168,7 +170,8 @@ class HumanObjectPeerTestInstance {
         final KeysManager explicit_keys_manager;
         final KeysInterface keys_interface;
         final ChainMonitor chain_monitor;
-        final NetGraphMsgHandler router;
+        final NetworkGraph router;
+        NetGraphMsgHandler route_handler;
         final Watch chain_watch;
         final HashSet<String> filter_additions;
         final Option_FilterZ filter;
@@ -183,6 +186,7 @@ class HumanObjectPeerTestInstance {
         final LinkedList<byte[]> received_custom_messages = new LinkedList<>();
         final LinkedList<byte[]> custom_messages_to_send = new LinkedList<>();
         ChannelManagerConstructor constructor = null;
+        InvoicePayer payer = null;
         GcCheck obj = new GcCheck();
 
         private TwoTuple_OutPointScriptZ test_mon_roundtrip(ChannelMonitor mon) {
@@ -209,7 +213,7 @@ class HumanObjectPeerTestInstance {
             this.seed = seed;
             Persist persister = Persist.new_impl(new Persist.PersistInterface() {
                 @Override
-                public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) {
+                public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data, MonitorUpdateId update_id) {
                     synchronized (monitors) {
                         String key = Arrays.toString(id.to_channel_id());
                         assert monitors.put(key, data) == null;
@@ -221,7 +225,7 @@ class HumanObjectPeerTestInstance {
                 }
 
                 @Override
-                public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) {
+                public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) {
                     synchronized (monitors) {
                         String key = Arrays.toString(id.to_channel_id());
                         assert monitors.put(key, data) != null;
@@ -268,7 +272,8 @@ class HumanObjectPeerTestInstance {
                 this.keys_interface = keys.as_KeysInterface();
                 this.explicit_keys_manager = keys;
             }
-            this.router = NetGraphMsgHandler.of(NetworkGraph.of(new byte[32]), Option_AccessZ.some(Access.new_impl(new Access.AccessInterface() {
+            this.router = NetworkGraph.of(new byte[32]);
+            this.route_handler = NetGraphMsgHandler.of(this.router, Option_AccessZ.some(Access.new_impl(new Access.AccessInterface() {
                 @Override
                 public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
                     // We don't exchange any gossip, so should never actually get called, but providing a Some(Access)
@@ -333,12 +338,15 @@ class HumanObjectPeerTestInstance {
         Peer(byte seed) {
             this(null, seed);
             if (use_chan_manager_constructor) {
-                NetGraphMsgHandler route_handler = null;
-                if (!use_ignore_handler) {
-                    route_handler = router;
+                if (use_ignore_handler) {
+                    this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0,
+                                                       this.keys_interface, this.fee_estimator, this.chain_monitor, null, this.tx_broadcaster, this.logger);
+                } else {
+                    this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0,
+                                                       this.keys_interface, this.fee_estimator, this.chain_monitor, this.router, this.tx_broadcaster, this.logger);
                 }
-                this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0,
-                        this.keys_interface, this.fee_estimator, this.chain_monitor, route_handler, this.tx_broadcaster, this.logger);
+                LockableScore scorer = null;
+                if (use_invoice_payer) { scorer = LockableScore.of(Scorer.with_default().as_Score()); }
                 constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
                     @Override public void handle_event(Event event) {
                         synchronized (pending_manager_events) {
@@ -347,15 +355,35 @@ class HumanObjectPeerTestInstance {
                         }
                     }
                     @Override public void persist_manager(byte[] channel_manager_bytes) { assert channel_manager_bytes.length > 1; }
-                });
+                }, scorer);
                 this.chan_manager = constructor.channel_manager;
                 this.peer_manager = constructor.peer_manager;
+                this.payer = constructor.payer;
                 must_free_objs.add(new WeakReference<>(this.chan_manager));
             } else {
                 ChainParameters params = ChainParameters.of(Network.LDKNetwork_Bitcoin, BestBlock.of(new byte[32], 0));
                 this.chan_manager = ChannelManager.of(this.fee_estimator, chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.with_default(), params);
                 byte[] random_data = keys_interface.get_secure_random_bytes();
-                this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
+                this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
+                if (use_invoice_payer) {
+                    this.payer = InvoicePayer.of(this.chan_manager.as_Payer(), Router.new_impl(new Router.RouterInterface() {
+                        @Override
+                        public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer) {
+                            return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer);
+                        }
+                    }), LockableScore.of(Score.new_impl(new Score.ScoreInterface() {
+                        @Override public void payment_path_failed(RouteHop[] path, long scid) {}
+                        @Override public long channel_penalty_msat(long scid, NodeId src, NodeId dst) { return 0; }
+                        @Override public byte[] write() { assert false; return null; }
+                    })), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
+                        @Override public void handle_event(Event event) {
+                            synchronized (pending_manager_events) {
+                                pending_manager_events.add(event);
+                                pending_manager_events.notifyAll();
+                            }
+                        }
+                    }), RetryAttempts.of(0));
+                }
             }
 
             this.node_id = chan_manager.get_our_node_id();
@@ -374,8 +402,15 @@ class HumanObjectPeerTestInstance {
                     if (this.filter instanceof Option_FilterZ.Some) {
                         filter_nullable = ((Option_FilterZ.Some) this.filter).some;
                     }
-                    this.constructor = new ChannelManagerConstructor(serialized, monitors, this.keys_interface,
-                            this.fee_estimator, this.chain_monitor, filter_nullable, this.router, this.tx_broadcaster, this.logger);
+                    if (use_ignore_handler) {
+                        this.constructor = new ChannelManagerConstructor(serialized, monitors, this.keys_interface,
+                                this.fee_estimator, this.chain_monitor, filter_nullable, null, this.tx_broadcaster, this.logger);
+                    } else {
+                        this.constructor = new ChannelManagerConstructor(serialized, monitors, this.keys_interface,
+                                this.fee_estimator, this.chain_monitor, filter_nullable, this.router, this.tx_broadcaster, this.logger);
+                    }
+                    LockableScore scorer = null;
+                    if (use_invoice_payer) { scorer = LockableScore.of(Scorer.with_default().as_Score()); }
                     constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
                         @Override public void handle_event(Event event) {
                             synchronized (pending_manager_events) {
@@ -384,8 +419,9 @@ class HumanObjectPeerTestInstance {
                             }
                         }
                         @Override public void persist_manager(byte[] channel_manager_bytes) { assert channel_manager_bytes.length > 1; }
-                    });
+                    }, scorer);
                     this.chan_manager = constructor.channel_manager;
+                    this.payer = constructor.payer;
                     this.peer_manager = constructor.peer_manager;
                     must_free_objs.add(new WeakReference<>(this.chan_manager));
                     // If we are using a ChannelManagerConstructor, we may have pending events waiting on the old peer
@@ -417,13 +453,32 @@ class HumanObjectPeerTestInstance {
                 this.chan_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK) read_res).res.get_b();
                 this.chain_watch.watch_channel(monitors[0].get_funding_txo().get_a(), monitors[0]);
                 byte[] random_data = keys_interface.get_secure_random_bytes();
-                this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), router.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
+                this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
                 if (!break_cross_peer_refs && (use_manual_watch || use_km_wrapper)) {
                     // When we pass monitors[0] into chain_watch.watch_channel we create a reference from the new Peer to a
                     // field in the old peer, preventing freeing of the original Peer until the new Peer is freed. Thus, we
                     // shouldn't bother waiting for the original to be freed later on.
                     cross_reload_ref_pollution = true;
                 }
+                if (use_invoice_payer) {
+                    this.payer = InvoicePayer.of(this.chan_manager.as_Payer(), Router.new_impl(new Router.RouterInterface() {
+                        @Override
+                        public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer) {
+                            return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer);
+                        }
+                    }), LockableScore.of(Score.new_impl(new Score.ScoreInterface() {
+                        @Override public void payment_path_failed(RouteHop[] path, long scid) {}
+                        @Override public long channel_penalty_msat(long scid, NodeId src, NodeId dst) { return 0; }
+                        @Override public byte[] write() { assert false; return null; }
+                    })), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
+                        @Override public void handle_event(Event event) {
+                            synchronized (pending_manager_events) {
+                                pending_manager_events.add(event);
+                                pending_manager_events.notifyAll();
+                            }
+                        }
+                    }), RetryAttempts.of(0));
+                }
             }
             this.node_id = chan_manager.get_our_node_id();
             bind_nio();
@@ -721,7 +776,7 @@ class HumanObjectPeerTestInstance {
         assert Arrays.equals(peer1_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
         assert Arrays.equals(peer2_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
 
-        Result_InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.keys_interface, Currency.LDKCurrency_Bitcoin, Option_u64Z.none(), "Invoice Description");
+        Result_InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.keys_interface, Currency.LDKCurrency_Bitcoin, Option_u64Z.some(10000000), "Invoice Description");
         assert invoice instanceof Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK;
         System.out.println("Got invoice: " + ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.to_str());
 
@@ -734,33 +789,41 @@ class HumanObjectPeerTestInstance {
         Description raw_invoice_description = raw_invoice.description();
         String description_string = raw_invoice_description.into_inner();
         assert description_string.equals("Invoice Description");
-        byte[] payment_hash = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_hash();
-        byte[] payment_secret = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_secret();
-        byte[] dest_node_id = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.recover_payee_pub_key();
-        assert Arrays.equals(dest_node_id, peer2.node_id);
-        InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features();
-        RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
-
-        Result_RouteLightningErrorZ route_res = UtilMethods.get_route(
-                peer1.chan_manager.get_our_node_id(), peer1.router.get_network_graph(), peer2.node_id, invoice_features,
-                peer1_chans, route_hints, 10000000, 42, peer1.logger, Scorer.with_default().as_Score());
-        assert route_res instanceof Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK;
-        Route route = ((Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK) route_res).res;
-        assert route.get_paths().length == 1;
-        assert route.get_paths()[0].length == 1;
-        assert route.get_paths()[0][0].get_fee_msat() == 10000000;
-
-        Result_PaymentIdPaymentSendFailureZ payment_res = peer1.chan_manager.send_payment(route, payment_hash, payment_secret);
-        assert payment_res instanceof Result_PaymentIdPaymentSendFailureZ.Result_PaymentIdPaymentSendFailureZ_OK;
-
-        RouteHop[][] hops = new RouteHop[1][1];
-        byte[] hop_pubkey = new byte[33];
-        hop_pubkey[0] = 3;
-        hop_pubkey[1] = 42;
-        hops[0][0] = RouteHop.of(hop_pubkey, NodeFeatures.known(), 42, ChannelFeatures.known(), 100, 0);
-        Route r2 = Route.of(hops);
-        payment_res = peer1.chan_manager.send_payment(r2, payment_hash, payment_secret);
-        assert payment_res instanceof Result_PaymentIdPaymentSendFailureZ.Result_PaymentIdPaymentSendFailureZ_Err;
+
+        if (!use_invoice_payer) {
+            byte[] payment_hash = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_hash();
+            byte[] payment_secret = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_secret();
+            byte[] dest_node_id = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.recover_payee_pub_key();
+            assert Arrays.equals(dest_node_id, peer2.node_id);
+            InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features();
+            RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
+
+            Payee payee = Payee.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none());
+            RouteParameters route_params = RouteParameters.of(payee, 10000000, 42);
+            Result_RouteLightningErrorZ route_res = UtilMethods.find_route(
+                    peer1.chan_manager.get_our_node_id(), route_params, peer1.router,
+                    peer1_chans, peer1.logger, Scorer.with_default().as_Score());
+            assert route_res instanceof Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK;
+            Route route = ((Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK) route_res).res;
+            assert route.get_paths().length == 1;
+            assert route.get_paths()[0].length == 1;
+            assert route.get_paths()[0][0].get_fee_msat() == 10000000;
+
+            Result_PaymentIdPaymentSendFailureZ payment_res = peer1.chan_manager.send_payment(route, payment_hash, payment_secret);
+            assert payment_res instanceof Result_PaymentIdPaymentSendFailureZ.Result_PaymentIdPaymentSendFailureZ_OK;
+
+            RouteHop[][] hops = new RouteHop[1][1];
+            byte[] hop_pubkey = new byte[33];
+            hop_pubkey[0] = 3;
+            hop_pubkey[1] = 42;
+            hops[0][0] = RouteHop.of(hop_pubkey, NodeFeatures.known(), 42, ChannelFeatures.known(), 100, 0);
+            Route r2 = Route.of(hops, payee);
+            payment_res = peer1.chan_manager.send_payment(r2, payment_hash, payment_secret);
+            assert payment_res instanceof Result_PaymentIdPaymentSendFailureZ.Result_PaymentIdPaymentSendFailureZ_Err;
+        } else {
+            Result_PaymentIdPaymentErrorZ send_res = peer1.payer.pay_invoice(((Result_InvoiceNoneZ.Result_InvoiceNoneZ_OK) parsed_invoice).res);
+            assert send_res instanceof Result_PaymentIdPaymentErrorZ.Result_PaymentIdPaymentErrorZ_OK;
+        }
 
         if (reload_peers) {
             if (use_chan_manager_constructor) {
@@ -978,14 +1041,14 @@ class HumanObjectPeerTestInstance {
     }
 }
 public class HumanObjectPeerTest {
-    HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor) throws InterruptedException {
-        HumanObjectPeerTestInstance instance = new HumanObjectPeerTestInstance(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, !nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor);
+    HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws InterruptedException {
+        HumanObjectPeerTestInstance instance = new HumanObjectPeerTestInstance(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, !nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         HumanObjectPeerTestInstance.TestState state = instance.do_test_message_handler();
         instance.do_test_message_handler_b(state);
         return instance;
     }
-    void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor) throws InterruptedException {
-        HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor);
+    void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws InterruptedException {
+        HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         while (instance.gc_count != instance.gc_exp_count) {
             System.gc();
             System.runFinalization();
@@ -995,15 +1058,16 @@ public class HumanObjectPeerTest {
     }
     @Test
     public void test_message_handler() throws InterruptedException {
-        for (int i = 0; i < (1 << 8) - 1; i++) {
+        for (int i = 0; i < (1 << 9) - 1; i++) {
             boolean nice_close =                   (i & (1 << 0)) != 0;
             boolean use_km_wrapper =               (i & (1 << 1)) != 0;
             boolean use_manual_watch =             (i & (1 << 2)) != 0;
             boolean reload_peers =                 (i & (1 << 3)) != 0;
             boolean break_cross_refs =             (i & (1 << 4)) != 0;
-            boolean nio_peer_handler =             (i & (1 << 5)) != 0;
-            boolean use_ignoring_routing_handler = (i & (1 << 6)) != 0;
-            boolean use_chan_manager_constructor = (i & (1 << 7)) != 0;
+            boolean use_ignoring_routing_handler = (i & (1 << 5)) != 0;
+            boolean use_chan_manager_constructor = (i & (1 << 6)) != 0;
+            boolean use_invoice_payer =            (i & (1 << 7)) != 0;
+            boolean nio_peer_handler =             (i & (1 << 8)) != 0;
             if (break_cross_refs && !reload_peers) {
                 // There are no cross refs to break without reloading peers.
                 continue;
@@ -1012,13 +1076,19 @@ public class HumanObjectPeerTest {
                 // ChannelManagerConstructor requires a ChainMonitor as the Watch and creates a NioPeerHandler for us.
                 continue;
             }
-            if (!use_chan_manager_constructor && use_ignoring_routing_handler) {
+            if (!use_chan_manager_constructor && (use_ignoring_routing_handler)) {
                 // We rely on the ChannelManagerConstructor to convert null into an IgnoringMessageHandler, so don't
                 // try to run with an IgnoringMessageHandler unless we're also using a ChannelManagerConstructor.
                 continue;
             }
+            if (use_chan_manager_constructor && use_ignoring_routing_handler && use_invoice_payer) {
+                // As documented on ChannelManagerConstructor, if we provide a `null` NetworkGraph (because we want to
+                // use an IgnoringMessageHandler), no InvoicePayer will be constructored for us, thus we cannot use an
+                // InvoicePayer to send payments in this case.
+                continue;
+            }
             System.err.println("Running test with flags " + i);
-            do_test(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor);
+            do_test(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         }
     }
 
index 660984197306f84e4bb009de8f9fa897cfadb378..8dc85de0d5c1eea676d3d9126dce32860639d05e 100644 (file)
@@ -24,6 +24,7 @@ public class PeerTest {
         final long chan_manager_events;
         final long chan_handler;
         final long router;
+        final long router_wrapper;
         final long route_handler;
         final long message_handler;
         final long custom_message_handler;
@@ -99,8 +100,9 @@ public class PeerTest {
             this.chan_manager_events = bindings.ChannelManager_as_EventsProvider(chan_manager);
 
             this.chan_handler = bindings.ChannelManager_as_ChannelMessageHandler(chan_manager);
-            this.router = bindings.NetGraphMsgHandler_new(bindings.NetworkGraph_new(new byte[32]), bindings.COption_AccessZ_none(), logger);
-            this.route_handler = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(router);
+            this.router = bindings.NetworkGraph_new(new byte[32]);
+            this.router_wrapper = bindings.NetGraphMsgHandler_new(router, bindings.COption_AccessZ_none(), logger);
+            this.route_handler = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(router_wrapper);
             this.message_handler = bindings.MessageHandler_new(chan_handler, route_handler);
             this.custom_message_handler = bindings.IgnoringMessageHandler_new();
 
@@ -142,7 +144,8 @@ public class PeerTest {
             bindings.ChannelManager_free(chan_manager);
             bindings.EventsProvider_free(chan_manager_events);
             bindings.ChannelMessageHandler_free(chan_handler);
-            bindings.NetGraphMsgHandler_free(router);
+            bindings.NetworkGraph_free(router);
+            bindings.NetGraphMsgHandler_free(router_wrapper);
             bindings.RoutingMessageHandler_free(route_handler);
             //MessageHandler was actually moved into the route_handler!: bindings.MessageHandler_free(message_handler);
             bindings.PeerManager_free(peer_manager);
@@ -279,16 +282,24 @@ public class PeerTest {
         long no_min_val = bindings.COption_u64Z_none();
         long inbound_payment = bindings.ChannelManager_create_inbound_payment(peer2.chan_manager, no_min_val, 7200, 42);
         bindings.COption_u64Z_free(no_min_val);
-        long netgraph = bindings.NetGraphMsgHandler_get_network_graph(peer1.router);
         long scorer = bindings.Scorer_default();
         long scorer_interface = bindings.Scorer_as_Score(scorer);
-        long route = bindings.get_route(peer1.node_id, netgraph, peer2.node_id, 0L, peer1_chans,
-                new long[0], 1000, 42, peer1.logger, scorer_interface);
+
+        long no_u64 = bindings.COption_u64Z_none();
+        long invoice_features = bindings.InvoiceFeatures_known();
+        long payee = bindings.Payee_new(peer2.node_id, invoice_features, new long[0], no_u64);
+        bindings.InvoiceFeatures_free(invoice_features);
+        bindings.COption_u64Z_free(no_u64);
+        long route_params = bindings.RouteParameters_new(payee, 1000, 42);
+        long route = bindings.find_route(peer1.node_id, route_params, peer1.router, peer1_chans,
+                peer1.logger, scorer_interface);
+        bindings.RouteParameters_free(route_params);
+        bindings.Payee_free(payee);
         bindings.Score_free(scorer_interface);
         bindings.Scorer_free(scorer);
+
         for (long chan : peer1_chans) bindings.ChannelDetails_free(chan);
         assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route);
-        bindings.NetworkGraph_free(netgraph);
         long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route),
                 bindings.C2Tuple_PaymentHashPaymentSecretZ_get_a(inbound_payment), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_b(inbound_payment));
         bindings.CResult_RouteLightningErrorZ_free(route);
index 4ac3369be4d92fe2e143a5c7c33c884ec2b6e50a..e738038d7ab8e066df6b516a242c6eff3d3e73a3 100644 (file)
@@ -18,9 +18,10 @@ void *malloc(size_t size);
 void free(void *ptr);
 
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); }
+#define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
+#define CHECK_ACCESS(p)
 
 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
@@ -384,18 +385,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDec
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
@@ -405,18 +408,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeys
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelPublicKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
@@ -426,9 +431,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErr
        LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
@@ -456,18 +462,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommi
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCOutputInCommitment res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
@@ -477,18 +485,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChann
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
@@ -498,18 +508,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactio
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
@@ -519,18 +531,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentT
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHolderCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
@@ -540,18 +554,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTr
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) {
@@ -561,9 +577,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTra
        LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedClosingTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
@@ -578,18 +595,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransac
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
@@ -599,9 +618,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitment
        LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
@@ -616,13 +636,15 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNo
        LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_SignatureZ res_var = (*val->contents.result);
-       ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
        for (size_t m = 0; m < res_var.datalen; m++) {
                int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
                res_arr_ptr[m] = res_conv_12_arr;
        }
+       
        return res_arr;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
@@ -637,18 +659,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDec
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
@@ -658,18 +682,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInv
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKInvalidShutdownScript err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
@@ -693,18 +719,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErr
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRouteHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
@@ -747,20 +775,71 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
+       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+       ret->datalen = *((uint32_t*)elems);
+       if (ret->datalen == 0) {
+               ret->data = NULL;
+       } else {
+               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ 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];
+                       LDKRouteHint arr_elem_conv;
+                       arr_elem_conv.inner = (void*)(arr_elem & (~1));
+                       arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       ret->data[i] = arr_elem_conv;
+               }
+       }
+       return (uint64_t)ret;
+}
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = RouteHint_clone(&orig->data[i]);
+       }
+       return ret;
+}
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
        LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
        switch(obj->tag) {
@@ -773,55 +852,124 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(
                default: abort();
        }
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
-       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKPayee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintHopZ_new(uint32_tArray elems) {
+       LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
        ret->datalen = *((uint32_t*)elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
+               ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ 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];
-                       LDKChannelDetails arr_elem_conv;
+                       LDKRouteHintHop arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
+                       arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
-       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
+       LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+               ret.data[i] = RouteHintHop_clone(&orig->data[i]);
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
-       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHintHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
+       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
        ret->datalen = *((uint32_t*)elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
+               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ 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];
-                       LDKRouteHint arr_elem_conv;
+                       LDKChannelDetails arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
-       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = RouteHint_clone(&orig->data[i]);
+               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
        }
        return ret;
 }
@@ -832,18 +980,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErr
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
@@ -861,17 +1011,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ
        uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
        return err_conv;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
-       LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
-       ret->a = a;
-       LDKTransaction b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       b_ref.data_is_owned = false;
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -903,7 +1042,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransac
                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_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -943,18 +1084,36 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(
        switch(obj->tag) {
                case LDKMonitorEvent_HTLCEvent: {
                        LDKHTLCUpdate htlc_event_var = obj->htlc_event;
+                       uint64_t htlc_event_ref = 0;
                        CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
+                       htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
                        return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
                }
                case LDKMonitorEvent_CommitmentTxConfirmed: {
                        LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
+                       uint64_t commitment_tx_confirmed_ref = 0;
                        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;
+                       commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
                        return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
                }
+               case LDKMonitorEvent_UpdateCompleted: {
+                       LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
+                       uint64_t funding_txo_ref = 0;
+                       CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
+                       return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
+               }
+               case LDKMonitorEvent_UpdateFailed: {
+                       LDKOutPoint update_failed_var = obj->update_failed;
+                       uint64_t update_failed_ref = 0;
+                       CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
+                       return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
+               }
                default: abort();
        }
 }
@@ -968,7 +1127,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(ui
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
                        arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1002,9 +1163,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr
        switch(obj->tag) {
                case LDKNetworkUpdate_ChannelUpdateMessage: {
                        LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
                }
                case LDKNetworkUpdate_ChannelClosed: {
@@ -1036,24 +1198,27 @@ uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_
        switch(obj->tag) {
                case LDKSpendableOutputDescriptor_StaticOutput: {
                        LDKOutPoint outpoint_var = obj->static_output.outpoint;
+                       uint64_t outpoint_ref = 0;
                        CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
+                       outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
                        uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
                        return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
                }
                case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
                        LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
+                       uint64_t delayed_payment_output_ref = 0;
                        CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
+                       delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
                        return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
                }
                case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
                        LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
+                       uint64_t static_payment_output_ref = 0;
                        CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
+                       static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
                        return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
                }
                default: abort();
@@ -1069,7 +1234,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescr
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
                        arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1088,9 +1255,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u
        switch(obj->tag) {
                case LDKErrorAction_DisconnectPeer: {
                        LDKErrorMessage msg_var = obj->disconnect_peer.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;
+                       uint64_t msg_ref = 0;
+                       if ((uint64_t)msg_var.inner > 4096) {
+                               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.
+                               msg_ref = (uint64_t)msg_var.inner & ~1;
+                       }
                        return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
                }
                case LDKErrorAction_IgnoreError: {
@@ -1102,9 +1272,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u
                }
                case LDKErrorAction_SendErrorMessage: {
                        LDKErrorMessage msg_var = obj->send_error_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
                }
                default: abort();
@@ -1117,133 +1288,149 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
                        LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendOpenChannel: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
                        LDKOpenChannel msg_var = obj->send_open_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingCreated: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
                        LDKFundingCreated msg_var = obj->send_funding_created.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingSigned: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
                        LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingLocked: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
                        LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendAnnouncementSignatures: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
                        LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_UpdateHTLCs: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
                        LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+                       uint64_t updates_ref = 0;
                        CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
+                       updates_ref = (uint64_t)updates_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
                }
                case LDKMessageSendEvent_SendRevokeAndACK: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
                        LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendClosingSigned: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
                        LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendShutdown: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
                        LDKShutdown msg_var = obj->send_shutdown.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendChannelReestablish: {
                        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_reestablish.node_id.compressed_form, 33);
                        LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
                        LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+                       uint64_t update_msg_ref = 0;
                        CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+                       update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
                }
                case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
                        LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
                }
                case LDKMessageSendEvent_BroadcastChannelUpdate: {
                        LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendChannelUpdate: {
                        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_update.node_id.compressed_form, 33);
                        LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_HandleError: {
@@ -1256,27 +1443,30 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_
                        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);
                        LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendShortIdsQuery: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
                        LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendReplyChannelRange: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
                        LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
                }
                default: abort();
@@ -1292,7 +1482,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_ne
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
                        arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1313,18 +1505,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecod
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInitFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1334,18 +1528,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecod
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1355,18 +1551,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDe
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1376,18 +1574,66 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDe
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoiceFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScoringParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScorer res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1397,18 +1643,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOut
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1418,18 +1666,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutp
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1445,9 +1695,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDe
        LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
@@ -1463,29 +1714,6 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uin
        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;
-       CHECK(*((uint32_t*)a) == 64);
-       memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
-       ret->a = a_ref;
-       LDKCVec_SignatureZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
-       else
-               b_constr.data = NULL;
-       int8_tArray* b_vals = (int8_tArray*)(b + 4);
-       for (size_t m = 0; m < b_constr.datalen; m++) {
-               int8_tArray b_conv_12 = b_vals[m];
-               LDKSignature b_conv_12_ref;
-               CHECK(*((uint32_t*)b_conv_12) == 64);
-               memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
-               b_constr.data[m] = b_conv_12_ref;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -1502,13 +1730,15 @@ static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(
 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
        LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -1598,15 +1828,18 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a
 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;
+       uint64_t holder_tx_ref = 0;
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1621,15 +1854,18 @@ LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1638,22 +1874,27 @@ LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const vo
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1666,7 +1907,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const vo
        int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
        uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1679,15 +1922,18 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
        int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
        uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1700,55 +1946,65 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
        int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
        uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        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, const LDKClosingTransaction * closing_tx) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKClosingTransaction closing_tx_var = *closing_tx;
-       // Warning: we may need a move here but no clone is available for LDKClosingTransaction
+       uint64_t closing_tx_ref = 0;
+       closing_tx_var = ClosingTransaction_clone(closing_tx);
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKUnsignedChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UnsignedChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+       uint64_t channel_parameters_ref = 0;
        channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
        CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+       channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
        if (channel_parameters_var.is_owned) {
                channel_parameters_ref |= 1;
        }
@@ -1795,21 +2051,27 @@ long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Objec
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
        return ret_arr;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction holder_tx_conv;
        holder_tx_conv.inner = (void*)(holder_tx & (~1));
        holder_tx_conv.is_owned = false;
@@ -1819,14 +2081,18 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_com
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
        return ret_arr;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -1836,7 +2102,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_c
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        unsigned char secret_arr[32];
        CHECK(*((uint32_t*)secret) == 32);
        memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
@@ -1847,7 +2115,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterpar
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -1857,7 +2127,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitm
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = *((uint32_t*)justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1873,7 +2145,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoke
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = *((uint32_t*)justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1892,7 +2166,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoke
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction htlc_tx_ref;
        htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
        htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1910,7 +2186,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_h
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKClosingTransaction closing_tx_conv;
        closing_tx_conv.inner = (void*)(closing_tx & (~1));
        closing_tx_conv.is_owned = false;
@@ -1920,7 +2198,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transa
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -1930,7 +2210,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announ
 }
 
 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelTransactionParameters channel_parameters_conv;
        channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
        channel_parameters_conv.is_owned = false;
@@ -1943,11 +2225,14 @@ LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
        return this_arg->pubkeys;
 }
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2006,7 +2291,9 @@ long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Re
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
-       LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
        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);
@@ -2020,7 +2307,7 @@ 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* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *res_ret = Sign_clone(&(*val->contents.result));
        return (uint64_t)res_ret;
 }
@@ -2028,9 +2315,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_
        LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
@@ -2062,7 +2350,8 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNon
        LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
-       ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
        for (size_t m = 0; m < res_var.datalen; m++) {
                LDKCVec_u8Z res_conv_12_var = res_var.data[m];
@@ -2070,6 +2359,7 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNon
                memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
                res_arr_ptr[m] = res_conv_12_arr;
        }
+       
        return res_arr;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
@@ -2084,18 +2374,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDec
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInMemorySigner res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
@@ -2108,7 +2400,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tA
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
                        arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2138,19 +2432,6 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKChannelMonitor b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelMonitor_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2167,9 +2448,10 @@ static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LD
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
        LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
        LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2186,7 +2468,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashCha
                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_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2207,7 +2491,8 @@ uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
-       uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
        uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
        for (size_t j = 0; j < res_var.datalen; j++) {
                LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
@@ -2215,6 +2500,7 @@ uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple
                *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
                res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
        }
+       
        return res_arr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
@@ -2223,27 +2509,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_Bloc
        uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
        return err_conv;
 }
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_result_ok(uint32_t arg) {
-       return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_get_ok(uint32_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKPaymentId 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_PaymentIdDecodeErrorZ_get_err(uint32_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(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;
-}
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
        LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
        switch(obj->tag) {
@@ -2284,9 +2549,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint
                }
                case LDKAPIError_IncompatibleShutdownScript: {
                        LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+                       uint64_t script_ref = 0;
                        CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t script_ref = (uint64_t)script_var.inner & ~1;
+                       script_ref = (uint64_t)script_var.inner & ~1;
                        return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
                }
                default: abort();
@@ -2316,7 +2582,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIError
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
                        arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2340,7 +2608,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
                        arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2379,7 +2649,8 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
                }
                case LDKPaymentSendFailure_PathParameterError: {
                        LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
-                       uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray path_parameter_error_arr = NULL;
+                       path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
                        for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
                                LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
@@ -2387,29 +2658,43 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
                                *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
                                path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
                        }
+                       
                        return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
                }
                case LDKPaymentSendFailure_AllFailedRetrySafe: {
                        LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
-                       uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray all_failed_retry_safe_arr = NULL;
+                       all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
                        for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
                                uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
                                all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
                        }
+                       
                        return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
                }
                case LDKPaymentSendFailure_PartialFailure: {
-                       LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
-                       uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
-                       uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
-                       for (size_t w = 0; w < partial_failure_var.datalen; w++) {
-                               LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
-                               *partial_failure_conv_22_conv = partial_failure_var.data[w];
-                               *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
-                               partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
+                       LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+                       uint32_tArray results_arr = NULL;
+                       results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
+                       for (size_t w = 0; w < results_var.datalen; w++) {
+                               LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+                               *results_conv_22_conv = results_var.data[w];
+                               *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+                               results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
+                       }
+                       
+                       LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+                       uint64_t failed_paths_retry_ref = 0;
+                       if ((uint64_t)failed_paths_retry_var.inner > 4096) {
+                               CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
                        }
-                       return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
+                       return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
                }
                default: abort();
        }
@@ -2417,14 +2702,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(uint32_t arg) {
        return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
+int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKPaymentId 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;
+       int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+       return res_arr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
@@ -2446,19 +2729,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFa
        uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2469,19 +2739,14 @@ int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymen
        return ret_arr;
 }
 
-static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
-       return PaymentId_clone(&tuple->b);
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+       return ThirtyTwoBytes_clone(&tuple->b);
 }
-uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
+int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
        LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
-       LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_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;
+       int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
+       return ret_arr;
 }
 
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(uint32_t arg) {
@@ -2537,7 +2802,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
                        arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2551,18 +2818,6 @@ static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddres
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
-       LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKThirtyTwoBytes b_ref;
-       CHECK(*((uint32_t*)b) == 32);
-       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2643,42 +2898,50 @@ static void LDKWatch_JCalls_free(void* this_arg) {
 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
        LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitor monitor_var = monitor;
+       uint64_t monitor_ref = 0;
        CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t monitor_ref = (uint64_t)monitor_var.inner;
+       monitor_ref = (uint64_t)monitor_var.inner;
        if (monitor_var.is_owned) {
                monitor_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
        LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = update;
+       uint64_t update_ref = 0;
        CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
+       update_ref = (uint64_t)update_var.inner;
        if (update_var.is_owned) {
                update_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2694,7 +2957,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void*
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t o = 0; o < ret_constr.datalen; o++) {
                uint32_t ret_conv_14 = ret_vals[o];
-               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
+               void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
+               CHECK_ACCESS(ret_conv_14_ptr);
+               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
                ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
                ret_constr.data[o] = ret_conv_14_conv;
        }
@@ -2724,7 +2989,9 @@ long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object R
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -2739,7 +3006,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -2754,16 +3023,20 @@ uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_
 }
 
 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -2809,7 +3082,9 @@ long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TO
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
-       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
        LDKTransaction tx_ref;
        tx_ref.datalen = *((uint32_t*)tx);
        tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
@@ -2870,7 +3145,9 @@ LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* t
 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
        LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
        uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
-       LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKSign ret_conv = *(LDKSign*)(ret_ptr);
        ret_conv = Sign_clone(&ret_conv);
        return ret_conv;
 }
@@ -2888,7 +3165,9 @@ LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void*
        int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
        uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
-       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2899,7 +3178,9 @@ LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const v
        memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
        CVec_u8Z_free(invoice_preimage_var);
        uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
-       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2931,14 +3212,18 @@ long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
        return ret_arr;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(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);
@@ -2947,11 +3232,14 @@ int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destina
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2959,21 +3247,27 @@ 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+       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) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
        return ret_arr;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKu8slice reader_ref;
        reader_ref.datalen = *((uint32_t*)reader);
        reader_ref.data = (int8_t*)(reader + 4);
@@ -2983,7 +3277,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_sign
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z invoice_preimage_ref;
        invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
        invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
@@ -3031,7 +3327,9 @@ long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS O
        return (long)res_ptr;
 }
 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
-       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
        LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
        int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
        return ret_val;
@@ -3075,19 +3373,6 @@ long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object
        *res_ptr = LDKLogger_init(o);
        return (long)res_ptr;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKChannelManager b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       // Warning: we need a move here but no clone is available for LDKChannelManager
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3104,9 +3389,10 @@ static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(L
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
        LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
        LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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 & ~1;
+       ret_ref = (uint64_t)ret_var.inner & ~1;
        return ret_ref;
 }
 
@@ -3116,8 +3402,7 @@ jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       *res_conv = (*val->contents.result);
+       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
        // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
        return ((uint64_t)res_conv) | 1;
 }
@@ -3125,9 +3410,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3137,18 +3423,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDeco
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelConfig res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3158,18 +3446,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErr
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOutPoint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKType_JCalls {
@@ -3231,13 +3521,17 @@ long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Re
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -3245,7 +3539,9 @@ jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
-       LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -3257,7 +3553,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr
        LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_TypeZ_Some: {
-                       LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
+                       LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
                        *some_ret = Type_clone(&obj->some);
                        return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
                }
@@ -3280,9 +3576,49 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDeco
        LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
+       LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+       switch(obj->tag) {
+               case LDKPaymentError_Invoice: {
+                       LDKStr invoice_str = obj->invoice;
+                       jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
+                       return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
+               }
+               case LDKPaymentError_Routing: {
+                       LDKLightningError routing_var = obj->routing;
+                       uint64_t routing_ref = 0;
+                       CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       routing_ref = (uint64_t)routing_var.inner & ~1;
+                       return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
+               }
+               case LDKPaymentError_Sending: {
+                       uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
+                       return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
+               }
+               default: abort();
+       }
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
+}
+int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+       return res_arr;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
@@ -3306,9 +3642,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_
        LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
@@ -3323,9 +3660,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceN
        LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKSignedRawInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
@@ -3333,33 +3671,16 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
-       LDKRawInvoice a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = RawInvoice_clone(&a_conv);
-       ret->a = a_conv;
-       LDKThirtyTwoBytes b_ref;
-       CHECK(*((uint32_t*)b) == 32);
-       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
-       ret->b = b_ref;
-       LDKInvoiceSignature c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = InvoiceSignature_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
        return RawInvoice_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3382,9 +3703,10 @@ static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignature
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3398,9 +3720,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ
        LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPayeePubKey res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
@@ -3442,9 +3765,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestamp
        LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPositiveTimestamp res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
@@ -3474,9 +3798,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticEr
        LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
@@ -3492,9 +3817,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreati
        LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDescription res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
@@ -3510,9 +3836,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreatio
        LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKExpiryTime res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
@@ -3528,9 +3855,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreat
        LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPrivateRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
@@ -3562,18 +3890,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpd
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelMonitorUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3583,18 +3913,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeE
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
@@ -3609,34 +3941,22 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdate
        LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKMonitorUpdateError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
-       LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
-       LDKOutPoint a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = OutPoint_clone(&a_conv);
-       ret->a = a_conv;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
        return OutPoint_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
        LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
        LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3655,16 +3975,6 @@ int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_g
        return ret_arr;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
-       LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
-       ret->a = a;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -3696,7 +4006,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_
                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_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3710,28 +4022,6 @@ static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const L
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32ScriptZZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
-       else
-               b_constr.data = NULL;
-       uint32_t* b_vals = (uint32_t*)(b + 4);
-       for (size_t v = 0; v < b_constr.datalen; v++) {
-               uint32_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
-               b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
-               b_constr.data[v] = b_conv_21_conv;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3748,13 +4038,15 @@ static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32Scr
 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 v = 0; v < ret_var.datalen; v++) {
                LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
                *ret_conv_21_conv = ret_var.data[v];
                ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -3769,7 +4061,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2T
                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_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3850,40 +4144,57 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_
                        return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
                }
                case LDKEvent_PaymentSent: {
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
                        int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
                        int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
-                       return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr; (void) payment_hash_arr;
+                       uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+                       return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
                }
                case LDKEvent_PaymentPathFailed: {
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
                        int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        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_tArray path_arr = NULL;
+                       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];
+                               uint64_t path_conv_10_ref = 0;
                                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_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
                                path_arr_ptr[k] = path_conv_10_ref;
                        }
+                       
                        uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
-                       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; (void) short_channel_id_ref;
+                       LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+                       uint64_t retry_ref = 0;
+                       if ((uint64_t)retry_var.inner > 4096) {
+                               CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               retry_ref = (uint64_t)retry_var.inner & ~1;
+                       }
+                       return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (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; (void) short_channel_id_ref; (void) retry_ref;
                }
                case LDKEvent_PendingHTLCsForwardable: {
                        return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
                }
                case LDKEvent_SpendableOutputs: {
                        LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
-                       uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray outputs_arr = NULL;
+                       outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
                        for (size_t b = 0; b < outputs_var.datalen; b++) {
                                uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
                                outputs_arr_ptr[b] = outputs_conv_27_ref;
                        }
+                       
                        return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
                }
                case LDKEvent_PaymentForwarded: {
@@ -3917,7 +4228,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tA
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
                        arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3931,14 +4244,6 @@ static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
-       LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
-       ret->a = a;
-       LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
-       b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -3968,7 +4273,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_n
                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_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3982,28 +4289,6 @@ static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDK
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32TxOutZZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
-       else
-               b_constr.data = NULL;
-       uint32_t* b_vals = (uint32_t*)(b + 4);
-       for (size_t u = 0; u < b_constr.datalen; u++) {
-               uint32_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
-               b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
-               b_constr.data[u] = b_conv_20_conv;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -4020,13 +4305,15 @@ static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOu
 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 u = 0; u < ret_var.datalen; u++) {
                LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
                *ret_conv_20_conv = ret_var.data[u];
                ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -4041,7 +4328,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2T
                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_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4083,7 +4372,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
                        arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4112,9 +4403,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
@@ -4129,22 +4421,12 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErro
        LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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;
-}
 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -4160,7 +4442,7 @@ static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTy
 }
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
        LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
-       LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
+       LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
        *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
        return (uint64_t)ret_ret;
 }
@@ -4175,7 +4457,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTyp
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4201,39 +4485,22 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErro
        LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
-       LDKChannelAnnouncement a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = ChannelAnnouncement_clone(&a_conv);
-       ret->a = a_conv;
-       LDKChannelUpdate b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelUpdate_clone(&b_conv);
-       ret->b = b_conv;
-       LDKChannelUpdate c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = ChannelUpdate_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
        return ChannelAnnouncement_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4246,9 +4513,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4261,9 +4529,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4280,7 +4549,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnou
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
                        arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4335,9 +4606,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandl
        LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
@@ -4352,9 +4624,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErr
        LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
@@ -4369,9 +4642,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErr
        LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4381,18 +4655,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeError
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeId res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKAccess_JCalls {
@@ -4411,7 +4687,9 @@ LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, cons
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
        ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -4437,7 +4715,9 @@ long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
        unsigned char genesis_hash_arr[32];
        CHECK(*((uint32_t*)genesis_hash) == 32);
        memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
@@ -4451,7 +4731,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_p
        LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_AccessZ_Some: {
-                       LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
+                       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;
@@ -4469,18 +4749,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChanne
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDirectionalChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       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);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4490,18 +4772,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecode
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4511,18 +4795,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecode
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoutingFees res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4532,18 +4818,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementI
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncementInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
@@ -4572,18 +4860,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErr
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4593,18 +4883,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecod
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNetworkGraph res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
@@ -4612,12 +4904,14 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_
        switch(obj->tag) {
                case LDKCOption_CVec_NetAddressZZ_Some: {
                        LDKCVec_NetAddressZ some_var = obj->some;
-                       uint32_tArray some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray some_arr = NULL;
+                       some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
                        for (size_t m = 0; m < some_var.datalen; m++) {
                                uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
                                some_arr_ptr[m] = some_conv_12_ref;
                        }
+                       
                        return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
                }
                case LDKCOption_CVec_NetAddressZZ_None: {
@@ -4626,40 +4920,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_
                default: abort();
        }
 }
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
-       return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(val->result_ok);
-       uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
-       return res_ref;
-}
-int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(!val->result_ok);
-       return *val->contents.err;
-}
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
-       return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *res_conv = (*val->contents.result);
-       *res_conv = CResult_NetAddressu8Z_clone(res_conv);
-       return (uint64_t)res_conv;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(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_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
        return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
 }
@@ -4673,9 +4933,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeE
        LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
@@ -4789,18 +5050,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDeco
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAcceptChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4810,18 +5073,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSigna
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAnnouncementSignatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4831,18 +5096,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablis
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelReestablish res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4852,18 +5119,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDeco
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4873,18 +5142,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeR
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSignedFeeRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4894,18 +5165,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedD
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4915,18 +5188,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDec
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingCreated res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4936,18 +5211,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDeco
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4957,18 +5234,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDeco
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingLocked res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4978,18 +5257,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInit res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4999,18 +5280,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecode
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOpenChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5020,18 +5303,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecod
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRevokeAndACK res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5041,18 +5326,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErr
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdown res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5062,18 +5349,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDec
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5083,18 +5372,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalform
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5104,18 +5395,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeEr
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5125,18 +5418,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLC
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFulfillHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5146,18 +5441,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDeco
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateAddHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5167,18 +5464,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPing res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5188,18 +5487,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPong res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5209,18 +5510,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAn
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5230,18 +5533,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnounceme
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5251,18 +5556,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUp
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5272,18 +5579,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDeco
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5293,18 +5602,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecod
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKErrorMessage res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5314,18 +5625,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnou
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5335,18 +5648,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementD
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5356,18 +5671,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannel
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryShortChannelIds res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5377,18 +5694,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannel
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5398,18 +5717,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRange
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5419,18 +5740,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRange
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5440,18 +5763,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFi
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKGossipTimestampFilter res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
@@ -5474,9 +5799,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCrea
        LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
@@ -5510,14 +5836,17 @@ void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32
 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;
+       uint64_t output_ref = 0;
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
        ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -5544,7 +5873,9 @@ long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
@@ -5556,7 +5887,9 @@ void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        LDKWatchedOutput output_conv;
        output_conv.inner = (void*)(output & (~1));
        output_conv.is_owned = (output & 1) || (output == 0);
@@ -5571,7 +5904,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_p
        LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_FilterZ_Some: {
-                       LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
+                       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;
@@ -5589,9 +5922,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMoni
        LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKLockedChannelMonitor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
@@ -5648,7 +5982,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t s = 0; s < ret_constr.datalen; s++) {
                uint32_t ret_conv_18 = ret_vals[s];
-               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
+               void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
+               CHECK_ACCESS(ret_conv_18_ptr);
+               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
                ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
                ret_constr.data[s] = ret_conv_18_conv;
        }
@@ -5676,16 +6012,20 @@ long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new
        return (long)res_ptr;
 }
 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
-       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
        LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 s = 0; s < ret_var.datalen; s++) {
                LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
-               *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
+               *ret_conv_18_copy = ret_var.data[s];
                uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
                ret_arr_ptr[s] = ret_conv_18_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -5729,7 +6069,9 @@ long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS O
        return (long)res_ptr;
 }
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
        LDKEvent* event_conv = (LDKEvent*)event;
        (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
 }
@@ -5747,7 +6089,7 @@ 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* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+       LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *handler_ret = handler;
        js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
 }
@@ -5773,8 +6115,12 @@ long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
-       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
-       LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
+       void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
+       CHECK_ACCESS(handler_ptr);
+       LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
        (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
 }
 
@@ -5827,7 +6173,9 @@ long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        LDKu8slice block_ref;
        block_ref.datalen = *((uint32_t*)block);
        block_ref.data = (int8_t*)(block + 4);
@@ -5835,7 +6183,9 @@ void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t
 }
 
 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5865,13 +6215,15 @@ void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t
        int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(header_arr + 4), *header, 80);
        LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
-       uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray txdata_arr = NULL;
+       txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
        uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
        for (size_t c = 0; c < txdata_var.datalen; c++) {
                LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
                *txdata_conv_28_conv = txdata_var.data[c];
                txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
        }
+       
        FREE(txdata_var.data);
        js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
 }
@@ -5931,7 +6283,9 @@ long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5945,7 +6299,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(u
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
@@ -5953,7 +6309,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(u
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
@@ -5962,7 +6320,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5971,15 +6331,19 @@ void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint3
 }
 
 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -5997,55 +6361,82 @@ static void LDKPersist_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       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);
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
+       uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        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) {
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = *update;
-       update_var = ChannelMonitorUpdate_clone(update);
-       CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
-       CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
-       if (update_var.is_owned) {
-               update_ref |= 1;
+       uint64_t update_ref = 0;
+       if ((uint64_t)update_var.inner > 4096) {
+               update_var = ChannelMonitorUpdate_clone(update);
+               CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               update_ref = (uint64_t)update_var.inner;
+               if (update_var.is_owned) {
+                       update_ref |= 1;
+               }
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
-       uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
+       uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6071,34 +6462,46 @@ long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object
        *res_ptr = LDKPersist_init(o);
        return (long)res_ptr;
 }
-uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitorUpdate update_conv;
        update_conv.inner = (void*)(update & (~1));
        update_conv.is_owned = false;
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
@@ -6157,17 +6560,19 @@ void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LD
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKOpenChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = OpenChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6178,17 +6583,19 @@ void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKAcceptChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AcceptChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6199,10 +6606,11 @@ void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingCreated msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingCreated_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6213,10 +6621,11 @@ void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6227,10 +6636,11 @@ void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingLocked msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingLocked_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6241,18 +6651,20 @@ void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPub
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = *their_features;
+       uint64_t their_features_ref = 0;
        their_features_var = InitFeatures_clone(their_features);
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKShutdown msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Shutdown_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6263,10 +6675,11 @@ void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKClosingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ClosingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6277,10 +6690,11 @@ void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateAddHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateAddHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6291,10 +6705,11 @@ void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFulfillHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFulfillHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6305,10 +6720,11 @@ void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFailHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6319,10 +6735,11 @@ void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFailMalformedHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailMalformedHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6333,10 +6750,11 @@ void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_ar
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKCommitmentSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = CommitmentSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6347,10 +6765,11 @@ void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKRevokeAndACK msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = RevokeAndACK_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6361,10 +6780,11 @@ void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKP
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFee msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFee_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6375,10 +6795,11 @@ void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* t
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKAnnouncementSignatures msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AnnouncementSignatures_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6395,10 +6816,11 @@ void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPubl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInit msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Init_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6409,10 +6831,11 @@ void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKChannelReestablish msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelReestablish_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6423,10 +6846,11 @@ void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6437,10 +6861,11 @@ void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublic
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKErrorMessage msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ErrorMessage_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6490,7 +6915,9 @@ long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*T
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6505,7 +6932,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_ope
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6520,7 +6949,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_acc
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6531,7 +6962,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6542,7 +6975,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6553,7 +6988,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6567,7 +7004,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shu
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6578,7 +7017,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_clo
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6589,7 +7030,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6600,7 +7043,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6611,7 +7056,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6622,7 +7069,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6633,7 +7082,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_com
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6644,7 +7095,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_rev
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6655,7 +7108,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6666,7 +7121,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_ann
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6674,7 +7131,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disco
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6685,7 +7144,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_conne
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6696,7 +7157,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_cha
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6707,7 +7170,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_cha
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6750,45 +7215,54 @@ static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKNodeAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = NodeAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6804,7 +7278,9 @@ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t h = 0; h < ret_constr.datalen; h++) {
                uint32_t ret_conv_59 = ret_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
+               void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
+               CHECK_ACCESS(ret_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
                ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
                ret_constr.data[h] = ret_conv_59_conv;
        }
@@ -6837,10 +7313,11 @@ void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDK
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInit init_var = *init;
+       uint64_t init_ref = 0;
        init_var = Init_clone(init);
        CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t init_ref = (uint64_t)init_var.inner;
+       init_ref = (uint64_t)init_var.inner;
        if (init_var.is_owned) {
                init_ref |= 1;
        }
@@ -6851,14 +7328,17 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKReplyChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6867,14 +7347,17 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKReplyShortChannelIdsEnd msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6883,14 +7366,17 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKQueryChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6899,14 +7385,17 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKQueryShortChannelIds msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6944,7 +7433,9 @@ long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*T
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKNodeAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6954,7 +7445,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6964,7 +7457,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelUpdate msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6974,43 +7469,54 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 h = 0; h < ret_var.datalen; h++) {
                LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
                *ret_conv_59_conv = ret_var.data[h];
                ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey starting_point_ref;
        CHECK(*((uint32_t*)starting_point) == 33);
        memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
        LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 s = 0; s < ret_var.datalen; s++) {
                LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
+               uint64_t ret_conv_18_ref = 0;
                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;
+               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;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7021,7 +7527,9 @@ void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routi
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7035,7 +7543,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7049,7 +7559,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7063,7 +7575,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7093,7 +7607,9 @@ LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const voi
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7119,7 +7635,9 @@ long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TOD
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
        LDKu8slice buffer_ref;
        buffer_ref.datalen = *((uint32_t*)buffer);
        buffer_ref.data = (int8_t*)(buffer + 4);
@@ -7144,12 +7662,14 @@ static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
 }
 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");
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7165,7 +7685,9 @@ LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandle
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t z = 0; z < ret_constr.datalen; z++) {
                uint32_t ret_conv_25 = ret_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
+               void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
+               CHECK_ACCESS(ret_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
                ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
                ret_constr.data[z] = ret_conv_25_conv;
        }
@@ -7197,8 +7719,12 @@ long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TO
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+       void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
+       CHECK_ACCESS(msg_ptr);
+       LDKType msg_conv = *(LDKType*)(msg_ptr);
        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);
@@ -7208,15 +7734,19 @@ uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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++) {
                LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
                *ret_conv_25_conv = ret_var.data[z];
                ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -7285,7 +7815,9 @@ long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO:
        return (long)res_ptr;
 }
 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = *((uint32_t*)data);
        data_ref.data = (int8_t*)(data + 4);
@@ -7294,12 +7826,16 @@ int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(ui
 }
 
 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
 }
 
 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
        return ret_val;
 }
@@ -7307,17 +7843,69 @@ int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_
 typedef struct LDKScore_JCalls {
        atomic_size_t refcnt;
        uint32_t channel_penalty_msat_meth;
+       uint32_t payment_path_failed_meth;
+       uint32_t write_meth;
 } LDKScore_JCalls;
 static void LDKScore_JCalls_free(void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
        if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
                js_free(j_calls->channel_penalty_msat_meth);
+               js_free(j_calls->payment_path_failed_meth);
+               js_free(j_calls->write_meth);
                FREE(j_calls);
        }
 }
-uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
+uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
+       LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+       LDKNodeId source_var = *source;
+       uint64_t source_ref = 0;
+       source_var = NodeId_clone(source);
+       CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       source_ref = (uint64_t)source_var.inner;
+       if (source_var.is_owned) {
+               source_ref |= 1;
+       }
+       LDKNodeId target_var = *target;
+       uint64_t target_ref = 0;
+       target_var = NodeId_clone(target);
+       CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       target_ref = (uint64_t)target_var.inner;
+       if (target_var.is_owned) {
+               target_ref |= 1;
+       }
+       return js_invoke_function_3(j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
+}
+void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+       LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+       LDKCVec_RouteHopZ path_var = path;
+       uint32_tArray path_arr = NULL;
+       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];
+               uint64_t path_conv_10_ref = 0;
+               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.
+               path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
+               if (path_conv_10_var.is_owned) {
+                       path_conv_10_ref |= 1;
+               }
+               path_arr_ptr[k] = path_conv_10_ref;
+       }
+       
+       FREE(path_var.data);
+       js_invoke_function_2(j_calls->payment_path_failed_meth, path_arr, short_channel_id);
+}
+LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
-       return js_invoke_function_1(j_calls->channel_penalty_msat_meth, short_channel_id);
+       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 LDKScore_JCalls_cloned(LDKScore* new_obj) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
@@ -7331,6 +7919,8 @@ static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
        LDKScore ret = {
                .this_arg = (void*) calls,
                .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
+               .payment_path_failed = payment_path_failed_LDKScore_jcall,
+               .write = write_LDKScore_jcall,
                .free = LDKScore_JCalls_free,
        };
        return ret;
@@ -7340,12 +7930,53 @@ long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object R
        *res_ptr = LDKScore_init(o);
        return (long)res_ptr;
 }
-int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id) {
-       LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
-       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
+int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       LDKNodeId source_conv;
+       source_conv.inner = (void*)(source & (~1));
+       source_conv.is_owned = false;
+       LDKNodeId target_conv;
+       target_conv.inner = (void*)(target & (~1));
+       target_conv.is_owned = false;
+       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
        return ret_val;
 }
 
+void  __attribute__((visibility("default"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+       }
+       (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Score_write(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+}
+
 typedef struct LDKChannelManagerPersister_JCalls {
        atomic_size_t refcnt;
        uint32_t persist_manager_meth;
@@ -7360,15 +7991,18 @@ static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
        LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
        LDKChannelManager channel_manager_var = *channel_manager;
+       uint64_t channel_manager_ref = 0;
        // Warning: we may need a move here but no clone is available for LDKChannelManager
        CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
+       channel_manager_ref = (uint64_t)channel_manager_var.inner;
        if (channel_manager_var.is_owned) {
                channel_manager_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
-       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7394,7 +8028,9 @@ long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
-       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
        LDKChannelManager channel_manager_conv;
        channel_manager_conv.inner = (void*)(channel_manager & (~1));
        channel_manager_conv.is_owned = false;
@@ -7426,6 +8062,293 @@ uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint
                default: abort();
        }
 }
+typedef struct LDKPayer_JCalls {
+       atomic_size_t refcnt;
+       uint32_t node_id_meth;
+       uint32_t first_hops_meth;
+       uint32_t send_payment_meth;
+       uint32_t retry_payment_meth;
+} LDKPayer_JCalls;
+static void LDKPayer_JCalls_free(void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+               js_free(j_calls->node_id_meth);
+               js_free(j_calls->first_hops_meth);
+               js_free(j_calls->send_payment_meth);
+               js_free(j_calls->retry_payment_meth);
+               FREE(j_calls);
+       }
+}
+LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       int8_tArray ret = js_invoke_function_0(j_calls->node_id_meth);
+       LDKPublicKey ret_ref;
+       CHECK(*((uint32_t*)ret) == 33);
+       memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
+       return ret_ref;
+}
+LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       uint32_tArray ret = js_invoke_function_0(j_calls->first_hops_meth);
+       LDKCVec_ChannelDetailsZ ret_constr;
+       ret_constr.datalen = *((uint32_t*)ret);
+       if (ret_constr.datalen > 0)
+               ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               ret_constr.data = NULL;
+       uint32_t* ret_vals = (uint32_t*)(ret + 4);
+       for (size_t q = 0; q < ret_constr.datalen; q++) {
+               uint32_t ret_conv_16 = ret_vals[q];
+               LDKChannelDetails ret_conv_16_conv;
+               ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
+               ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
+               ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
+               ret_constr.data[q] = ret_conv_16_conv;
+       }
+       return ret_constr;
+}
+LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_hash_arr + 4), payment_hash.data, 32);
+       int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_secret_arr + 4), payment_secret.data, 32);
+       uint32_t ret = js_invoke_function_3(j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
+       uint32_t ret = js_invoke_function_2(j_calls->retry_payment_meth, route_ref, payment_id_arr);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKPayer LDKPayer_init (/*TODO: JS Object Reference */void* o) {
+       LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       //TODO: Assign calls->o from o
+
+       LDKPayer ret = {
+               .this_arg = (void*) calls,
+               .node_id = node_id_LDKPayer_jcall,
+               .first_hops = first_hops_LDKPayer_jcall,
+               .send_payment = send_payment_LDKPayer_jcall,
+               .retry_payment = retry_payment_LDKPayer_jcall,
+               .free = LDKPayer_JCalls_free,
+       };
+       return ret;
+}
+long  __attribute__((visibility("default"))) TS_LDKPayer_new(/*TODO: JS Object Reference */void* o) {
+       LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *res_ptr = LDKPayer_init(o);
+       return (long)res_ptr;
+}
+int8_tArray  __attribute__((visibility("default"))) TS_Payer_node_id(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
+       return ret_arr;
+}
+
+uint32_tArray  __attribute__((visibility("default"))) TS_Payer_first_hops(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
+       uint32_tArray ret_arr = NULL;
+       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++) {
+               LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
+               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.
+               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;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_hash_ref;
+       CHECK(*((uint32_t*)payment_hash) == 32);
+       memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
+       LDKThirtyTwoBytes payment_secret_ref;
+       CHECK(*((uint32_t*)payment_secret) == 32);
+       memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
+       LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
+       LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
+       return (uint64_t)ret_conv;
+}
+
+typedef struct LDKRouter_JCalls {
+       atomic_size_t refcnt;
+       uint32_t find_route_meth;
+} LDKRouter_JCalls;
+static void LDKRouter_JCalls_free(void* this_arg) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+       if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+               js_free(j_calls->find_route_meth);
+               FREE(j_calls);
+       }
+}
+LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+       int8_tArray payer_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payer_arr + 4), payer.compressed_form, 33);
+       LDKRouteParameters params_var = *params;
+       uint64_t params_ref = 0;
+       params_var = RouteParameters_clone(params);
+       CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       params_ref = (uint64_t)params_var.inner;
+       if (params_var.is_owned) {
+               params_ref |= 1;
+       }
+       LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
+       uint32_tArray first_hops_arr = NULL;
+       if (first_hops != NULL) {
+               LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
+               first_hops_arr = init_arr(first_hops_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+               uint32_t *first_hops_arr_ptr = (uint32_t*)(first_hops_arr + 4);
+               for (size_t q = 0; q < first_hops_var.datalen; q++) {
+                       LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
+                       uint64_t first_hops_conv_16_ref = 0;
+                       CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
+                       if (first_hops_conv_16_var.is_owned) {
+                               first_hops_conv_16_ref |= 1;
+                       }
+                       first_hops_arr_ptr[q] = first_hops_conv_16_ref;
+               }
+       
+       }
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_scorer = ((uint64_t)scorer) | 1;
+       uint32_t ret = js_invoke_function_4(j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
+       ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKRouter LDKRouter_init (/*TODO: JS Object Reference */void* o) {
+       LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       //TODO: Assign calls->o from o
+
+       LDKRouter ret = {
+               .this_arg = (void*) calls,
+               .find_route = find_route_LDKRouter_jcall,
+               .free = LDKRouter_JCalls_free,
+       };
+       return ret;
+}
+long  __attribute__((visibility("default"))) TS_LDKRouter_new(/*TODO: JS Object Reference */void* o) {
+       LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *res_ptr = LDKRouter_init(o);
+       return (long)res_ptr;
+}
+uint32_t  __attribute__((visibility("default"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t params, uint32_tArray first_hops, uint32_t scorer) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
+       LDKPublicKey payer_ref;
+       CHECK(*((uint32_t*)payer) == 33);
+       memcpy(payer_ref.compressed_form, (uint8_t*)(payer + 4), 33);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
+       LDKCVec_ChannelDetailsZ first_hops_constr;
+       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
+       if (first_hops != 0) {
+               first_hops_constr.datalen = *((uint32_t*)first_hops);
+               if (first_hops_constr.datalen > 0)
+                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+               else
+                       first_hops_constr.data = NULL;
+               uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
+               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
+                       uint32_t first_hops_conv_16 = first_hops_vals[q];
+                       LDKChannelDetails first_hops_conv_16_conv;
+                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
+                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
+                       first_hops_constr.data[q] = first_hops_conv_16_conv;
+               }
+               first_hops_ptr = &first_hops_constr;
+       }
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
+       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
+       *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
+       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+       return (uint64_t)ret_conv;
+}
+
 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
        LDKStr ret_str = _ldk_get_compiled_version();
        jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
@@ -7461,7 +8384,9 @@ uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script
 
 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
        FREE((void*)_res);
        TxOut_free(_res_conv);
 }
@@ -7496,7 +8421,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(
 
 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SecretKeyErrorZ_free(_res_conv);
 }
@@ -7519,7 +8446,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(
 
 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PublicKeyErrorZ_free(_res_conv);
 }
@@ -7553,7 +8482,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
 }
@@ -7587,7 +8518,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDec
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
 }
@@ -7618,7 +8551,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysErrorZ_free(_res_conv);
 }
@@ -7646,7 +8581,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u32Z_free(_res_conv);
 }
@@ -7681,7 +8618,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitme
 
 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
 }
@@ -7715,7 +8654,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelT
 
 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -7749,7 +8690,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionPa
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -7801,7 +8744,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTran
 
 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7835,7 +8780,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTrans
 
 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7865,7 +8812,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransa
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
 }
@@ -7892,7 +8841,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactio
 
 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7922,7 +8873,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTra
 
 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
 }
@@ -7955,7 +8908,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
@@ -7989,7 +8944,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
 }
@@ -8015,7 +8972,7 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvali
        LDKInvalidShutdownScript e_conv;
        e_conv.inner = (void*)(e & (~1));
        e_conv.is_owned = (e & 1) || (e == 0);
-       // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
+       e_conv = InvalidShutdownScript_clone(&e_conv);
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
        *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
        return (uint64_t)ret_conv;
@@ -8023,14 +8980,23 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvali
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
-       LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
-       *ret_conv = CResult_NoneErrorZ_ok();
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
+       *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
+       LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
+       *ret_conv = CResult_NoneErrorZ_ok();
        return (uint64_t)ret_conv;
 }
 
@@ -8043,7 +9009,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint3
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneErrorZ_free(_res_conv);
 }
@@ -8077,7 +9045,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteHopDecodeErrorZ_free(_res_conv);
 }
@@ -8158,7 +9128,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteDecodeErrorZ_free(_res_conv);
 }
@@ -8170,6 +9142,60 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_cl
        return (uint64_t)ret_conv;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteParameters o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteParameters_clone(&o_conv);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteParametersDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
+       LDKCVec_RouteHintZ _res_constr;
+       _res_constr.datalen = *((uint32_t*)_res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               _res_constr.data = NULL;
+       uint32_t* _res_vals = (uint32_t*)(_res + 4);
+       for (size_t l = 0; l < _res_constr.datalen; l++) {
+               uint32_t _res_conv_11 = _res_vals[l];
+               LDKRouteHint _res_conv_11_conv;
+               _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
+               _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
+               _res_constr.data[l] = _res_conv_11_conv;
+       }
+       CVec_RouteHintZ_free(_res_constr);
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
        *ret_copy = COption_u64Z_some(o);
@@ -8186,7 +9212,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u64Z_free(_res_conv);
 }
@@ -8199,6 +9227,132 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t
        return ret_ref;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Payee_clone(&o_conv);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PayeeDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
+       LDKCVec_RouteHintHopZ _res_constr;
+       _res_constr.datalen = *((uint32_t*)_res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               _res_constr.data = NULL;
+       uint32_t* _res_vals = (uint32_t*)(_res + 4);
+       for (size_t o = 0; o < _res_constr.datalen; o++) {
+               uint32_t _res_conv_14 = _res_vals[o];
+               LDKRouteHintHop _res_conv_14_conv;
+               _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
+               _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
+               _res_constr.data[o] = _res_conv_14_conv;
+       }
+       CVec_RouteHintHopZ_free(_res_constr);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteHint o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHint_clone(&o_conv);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteHintHop o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHintHop_clone(&o_conv);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
        LDKCVec_ChannelDetailsZ _res_constr;
        _res_constr.datalen = *((uint32_t*)_res);
@@ -8217,24 +9371,6 @@ void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32
        CVec_ChannelDetailsZ_free(_res_constr);
 }
 
-void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
-       LDKCVec_RouteHintZ _res_constr;
-       _res_constr.datalen = *((uint32_t*)_res);
-       if (_res_constr.datalen > 0)
-               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               _res_constr.data = NULL;
-       uint32_t* _res_vals = (uint32_t*)(_res + 4);
-       for (size_t l = 0; l < _res_constr.datalen; l++) {
-               uint32_t _res_conv_11 = _res_vals[l];
-               LDKRouteHint _res_conv_11_conv;
-               _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
-               _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
-               _res_constr.data[l] = _res_conv_11_conv;
-       }
-       CVec_RouteHintZ_free(_res_constr);
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
        LDKRoute o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -8257,7 +9393,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteLightningErrorZ_free(_res_conv);
 }
@@ -8270,7 +9408,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
        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);
@@ -8286,7 +9426,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxOutAccessErrorZ_free(_res_conv);
 }
@@ -8318,7 +9460,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_ne
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_usizeTransactionZ_free(_res_conv);
 }
@@ -8333,7 +9477,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_
        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_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
+               void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
+               CHECK_ACCESS(_res_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
                FREE((void*)_res_conv_28);
                _res_constr.data[c] = _res_conv_28_conv;
        }
@@ -8373,7 +9519,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUp
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
 }
@@ -8395,7 +9543,9 @@ void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_t
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                uint32_t _res_conv_14 = _res_vals[o];
-               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
+               void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
+               CHECK_ACCESS(_res_conv_14_ptr);
+               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
                FREE((void*)_res_conv_14);
                _res_constr.data[o] = _res_conv_14_conv;
        }
@@ -8403,7 +9553,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
        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);
@@ -8420,7 +9572,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac
 
 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
 }
@@ -8434,7 +9588,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
-       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
        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);
@@ -8451,7 +9607,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none(
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        COption_NetworkUpdateZ_free(_res_conv);
 }
@@ -8474,7 +9632,9 @@ void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t b = 0; b < _res_constr.datalen; b++) {
                uint32_t _res_conv_27 = _res_vals[b];
-               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
+               void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
+               CHECK_ACCESS(_res_conv_27_ptr);
+               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
                FREE((void*)_res_conv_27);
                _res_constr.data[b] = _res_conv_27_conv;
        }
@@ -8491,7 +9651,9 @@ void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t s = 0; s < _res_constr.datalen; s++) {
                uint32_t _res_conv_18 = _res_vals[s];
-               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
+               void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
+               CHECK_ACCESS(_res_conv_18_ptr);
+               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
                FREE((void*)_res_conv_18);
                _res_constr.data[s] = _res_conv_18_conv;
        }
@@ -8520,7 +9682,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8547,7 +9711,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8574,7 +9740,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecod
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8601,11 +9769,71 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecod
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
+       LDKScoringParameters 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 LDKScoringParameters
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
+       LDKScorer 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 LDKScorer
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScorerDecodeErrorZ_free(_res_conv);
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
        LDKDelayedPaymentOutputDescriptor o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -8628,7 +9856,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutput
 
 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8662,7 +9892,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputD
 
 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8675,7 +9907,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
        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);
@@ -8694,7 +9928,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescr
 
 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8720,7 +9956,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneNoneZ_free(_res_conv);
 }
@@ -8764,13 +10002,17 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_Signat
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
        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);
@@ -8785,7 +10027,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVe
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
@@ -8814,7 +10058,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err()
 
 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignatureNoneZ_free(_res_conv);
 }
@@ -8827,7 +10073,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
-       LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSign o_conv = *(LDKSign*)(o_ptr);
        LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
        *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
        return (uint64_t)ret_conv;
@@ -8845,7 +10093,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignDecodeErrorZ_free(_res_conv);
 }
@@ -8882,7 +10132,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignature
 
 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RecoverableSignatureNoneZ_free(_res_conv);
 }
@@ -8942,7 +10194,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
 }
@@ -8976,7 +10230,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
 }
@@ -8998,7 +10254,9 @@ void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_7 = _res_vals[h];
-               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -9024,7 +10282,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TransactionNoneZ_free(_res_conv);
 }
@@ -9058,7 +10318,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMoni
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
 }
@@ -9073,7 +10335,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMon
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t j = 0; j < _res_constr.datalen; j++) {
                uint32_t _res_conv_35 = _res_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
+               void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
+               CHECK_ACCESS(_res_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
                FREE((void*)_res_conv_35);
                _res_constr.data[j] = _res_conv_35_conv;
        }
@@ -9090,7 +10354,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
        uint32_t* o_vals = (uint32_t*)(o + 4);
        for (size_t j = 0; j < o_constr.datalen; j++) {
                uint32_t o_conv_35 = o_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
+               void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
+               CHECK_ACCESS(o_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
                o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
                o_constr.data[j] = o_conv_35_conv;
        }
@@ -9108,7 +10374,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
 }
@@ -9120,40 +10388,6 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_ok(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
-       return (uint64_t)ret_conv;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_PaymentIdDecodeErrorZ_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_clone(uint32_t orig) {
-       LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
        LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
        *ret_copy = COption_u16Z_some(o);
@@ -9170,7 +10404,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u16Z_free(_res_conv);
 }
@@ -9190,7 +10426,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -9199,7 +10437,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(ui
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneAPIErrorZ_free(_res_conv);
 }
@@ -9221,7 +10461,9 @@ void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t w = 0; w < _res_constr.datalen; w++) {
                uint32_t _res_conv_22 = _res_vals[w];
-               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
+               void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
+               CHECK_ACCESS(_res_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
                FREE((void*)_res_conv_22);
                _res_constr.data[w] = _res_conv_22_conv;
        }
@@ -9238,7 +10480,9 @@ void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArra
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t k = 0; k < _res_constr.datalen; k++) {
                uint32_t _res_conv_10 = _res_vals[k];
-               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
+               void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
+               CHECK_ACCESS(_res_conv_10_ptr);
+               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
                FREE((void*)_res_conv_10);
                _res_constr.data[k] = _res_conv_10_conv;
        }
@@ -9255,7 +10499,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(in
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
-       LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
        LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
        *ret_conv = CResult__u832APIErrorZ_err(e_conv);
@@ -9264,7 +10510,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(u
 
 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult__u832APIErrorZ_free(_res_conv);
 }
@@ -9276,18 +10524,19 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK(*((uint32_t*)o) == 32);
+       memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
-       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
+       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
        return (uint64_t)ret_conv;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
        *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
@@ -9296,7 +10545,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSend
 
 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
 }
@@ -9315,7 +10566,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        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);
@@ -9324,7 +10577,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailu
 
 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePaymentSendFailureZ_free(_res_conv);
 }
@@ -9343,28 +10598,31 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentId
        return ((uint64_t)ret_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
+uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
        LDKThirtyTwoBytes a_ref;
        CHECK(*((uint32_t*)a) == 32);
        memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
+       LDKThirtyTwoBytes b_ref;
+       CHECK(*((uint32_t*)b) == 32);
+       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
        LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
+       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
        return ((uint64_t)ret_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
-       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
        o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
@@ -9372,7 +10630,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashP
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
@@ -9381,7 +10641,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashP
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
 }
@@ -9403,7 +10665,9 @@ void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tAr
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t m = 0; m < _res_constr.datalen; m++) {
                uint32_t _res_conv_12 = _res_vals[m];
-               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
+               void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
+               CHECK_ACCESS(_res_conv_12_ptr);
+               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
                FREE((void*)_res_conv_12);
                _res_constr.data[m] = _res_conv_12_conv;
        }
@@ -9431,7 +10695,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSe
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
 }
@@ -9446,7 +10712,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -9455,7 +10723,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErro
 
 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentSecretAPIErrorZ_free(_res_conv);
 }
@@ -9500,13 +10770,17 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMana
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
-       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
        // 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);
@@ -9525,7 +10799,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashCha
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
 }
@@ -9552,7 +10828,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
 }
@@ -9586,7 +10864,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OutPointDecodeErrorZ_free(_res_conv);
 }
@@ -9599,7 +10879,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
-       LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKType o_conv = *(LDKType*)(o_ptr);
        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;
@@ -9615,7 +10897,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
        FREE((void*)_res);
        COption_TypeZ_free(_res_conv);
 }
@@ -9629,7 +10913,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
-       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
        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);
@@ -9648,7 +10934,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
 }
@@ -9660,6 +10948,41 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeE
        return (uint64_t)ret_conv;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK(*((uint32_t*)o) == 32);
+       memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
+       e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PaymentIdPaymentErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
+       LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_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");
@@ -9675,7 +10998,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err()
 
 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SiPrefixNoneZ_free(_res_conv);
 }
@@ -9705,7 +11030,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceNoneZ_free(_res_conv);
 }
@@ -9735,7 +11062,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNone
 
 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignedRawInvoiceNoneZ_free(_res_conv);
 }
@@ -9773,7 +11102,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832Invoi
 
 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
 }
@@ -9797,7 +11128,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PayeePubKeyErrorZ_free(_res_conv);
 }
@@ -9846,7 +11179,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCre
 
 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
 }
@@ -9873,7 +11208,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_e
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneSemanticErrorZ_free(_res_conv);
 }
@@ -9904,7 +11241,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticError
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSemanticErrorZ_free(_res_conv);
 }
@@ -9935,7 +11274,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationE
 
 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DescriptionCreationErrorZ_free(_res_conv);
 }
@@ -9966,7 +11307,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationEr
 
 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
 }
@@ -9997,7 +11340,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreation
 
 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PrivateRouteCreationErrorZ_free(_res_conv);
 }
@@ -10025,7 +11370,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uin
 
 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StringErrorZ_free(_res_conv);
 }
@@ -10052,7 +11399,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdate
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -10086,7 +11435,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErro
 
 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -10116,7 +11467,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErr
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
 }
@@ -10151,7 +11504,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_OutPointScriptZ_free(_res_conv);
 }
@@ -10175,7 +11530,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32ScriptZ_free(_res_conv);
 }
@@ -10190,7 +11547,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(ui
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t v = 0; v < _res_constr.datalen; v++) {
                uint32_t _res_conv_21 = _res_vals[v];
-               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
+               void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
+               CHECK_ACCESS(_res_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
                FREE((void*)_res_conv_21);
                _res_constr.data[v] = _res_conv_21_conv;
        }
@@ -10217,7 +11576,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
        uint32_t* b_vals = (uint32_t*)(b + 4);
        for (size_t v = 0; v < b_constr.datalen; v++) {
                uint32_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
+               void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
+               CHECK_ACCESS(b_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
                b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
                b_constr.data[v] = b_conv_21_conv;
        }
@@ -10228,7 +11589,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
 }
@@ -10243,7 +11606,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                uint32_t _res_conv_40 = _res_vals[o];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
+               void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
+               CHECK_ACCESS(_res_conv_40_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
                FREE((void*)_res_conv_40);
                _res_constr.data[o] = _res_conv_40_conv;
        }
@@ -10260,7 +11625,9 @@ void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_7 = _res_vals[h];
-               LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -10295,7 +11662,9 @@ 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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
        b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
        LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
@@ -10304,7 +11673,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32TxOutZ_free(_res_conv);
 }
@@ -10319,7 +11690,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uin
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t u = 0; u < _res_constr.datalen; u++) {
                uint32_t _res_conv_20 = _res_vals[u];
-               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
+               void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
+               CHECK_ACCESS(_res_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
                FREE((void*)_res_conv_20);
                _res_constr.data[u] = _res_conv_20_conv;
        }
@@ -10346,7 +11719,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
        uint32_t* b_vals = (uint32_t*)(b + 4);
        for (size_t u = 0; u < b_constr.datalen; u++) {
                uint32_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
+               void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
+               CHECK_ACCESS(b_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
                b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
                b_constr.data[u] = b_conv_20_conv;
        }
@@ -10357,7 +11732,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
 }
@@ -10372,7 +11749,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t n = 0; n < _res_constr.datalen; n++) {
                uint32_t _res_conv_39 = _res_vals[n];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
+               void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
+               CHECK_ACCESS(_res_conv_39_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
                FREE((void*)_res_conv_39);
                _res_constr.data[n] = _res_conv_39_conv;
        }
@@ -10389,7 +11768,9 @@ void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray
        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);
+               void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
+               CHECK_ACCESS(_res_conv_9_ptr);
+               LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
                FREE((void*)_res_conv_9);
                _res_constr.data[j] = _res_conv_9_conv;
        }
@@ -10397,7 +11778,9 @@ void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
-       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
        o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
@@ -10416,7 +11799,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashCha
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
 }
@@ -10446,7 +11831,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneLightningErrorZ_free(_res_conv);
 }
@@ -10469,7 +11856,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(i
        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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKType b_conv = *(LDKType*)(b_ptr);
        LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
        *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
        return ((uint64_t)ret_conv);
@@ -10477,7 +11866,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(i
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PublicKeyTypeZ_free(_res_conv);
 }
@@ -10492,7 +11883,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_fre
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t z = 0; z < _res_constr.datalen; z++) {
                uint32_t _res_conv_25 = _res_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
+               void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
+               CHECK_ACCESS(_res_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
                FREE((void*)_res_conv_25);
                _res_constr.data[z] = _res_conv_25_conv;
        }
@@ -10517,7 +11910,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolLightningErrorZ_free(_res_conv);
 }
@@ -10556,7 +11951,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementC
 
 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
 }
@@ -10571,7 +11968,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncement
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_59 = _res_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
+               void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
+               CHECK_ACCESS(_res_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
                FREE((void*)_res_conv_59);
                _res_constr.data[h] = _res_conv_59_conv;
        }
@@ -10636,7 +12035,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleEr
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
 }
@@ -10666,7 +12067,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePeerHandleErrorZ_free(_res_conv);
 }
@@ -10696,7 +12099,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolPeerHandleErrorZ_free(_res_conv);
 }
@@ -10730,7 +12135,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_e
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeIdDecodeErrorZ_free(_res_conv);
 }
@@ -10743,7 +12150,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_c
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
-       LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKAccess o_conv = *(LDKAccess*)(o_ptr);
        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;
@@ -10759,7 +12168,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
        FREE((void*)_res);
        COption_AccessZ_free(_res_conv);
 }
@@ -10786,7 +12197,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelIn
 
 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10820,7 +12233,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10854,7 +12269,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
 }
@@ -10888,7 +12305,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfo
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10937,7 +12356,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10971,7 +12392,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
 }
@@ -10993,7 +12416,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_so
        uint32_t* o_vals = (uint32_t*)(o + 4);
        for (size_t m = 0; m < o_constr.datalen; m++) {
                uint32_t o_conv_12 = o_vals[m];
-               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
+               void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
+               CHECK_ACCESS(o_conv_12_ptr);
+               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
                o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
                o_constr.data[m] = o_conv_12_conv;
        }
@@ -11012,7 +12437,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_no
 
 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_CVec_NetAddressZZ_free(_res_conv);
 }
@@ -11025,68 +12452,10 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_cl
        return ret_ref;
 }
 
-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;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_err(e);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_NetAddressu8Z_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
-       LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
-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;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
-       LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
        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);
@@ -11105,7 +12474,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErro
 
 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetAddressDecodeErrorZ_free(_res_conv);
 }
@@ -11211,7 +12582,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
 }
@@ -11245,7 +12618,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignatur
 
 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11279,7 +12654,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDe
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
 }
@@ -11313,7 +12690,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11347,7 +12726,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRang
 
 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
 }
@@ -11381,7 +12762,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDeco
 
 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11415,7 +12798,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
 }
@@ -11449,7 +12834,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11483,7 +12870,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingLockedDecodeErrorZ_free(_res_conv);
 }
@@ -11517,7 +12906,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitDecodeErrorZ_free(_res_conv);
 }
@@ -11551,7 +12942,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OpenChannelDecodeErrorZ_free(_res_conv);
 }
@@ -11585,7 +12978,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
 }
@@ -11619,7 +13014,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownDecodeErrorZ_free(_res_conv);
 }
@@ -11653,7 +13050,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11687,7 +13086,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedH
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11721,7 +13122,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeError
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
 }
@@ -11755,7 +13158,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDec
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11789,7 +13194,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11823,7 +13230,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PingDecodeErrorZ_free(_res_conv);
 }
@@ -11857,7 +13266,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PongDecodeErrorZ_free(_res_conv);
 }
@@ -11891,7 +13302,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnou
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -11925,7 +13338,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementD
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -11959,7 +13374,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdat
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -11993,7 +13410,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -12027,7 +13446,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
 }
@@ -12061,7 +13482,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnounce
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -12095,7 +13518,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDeco
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -12129,7 +13554,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIds
 
 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
 }
@@ -12163,7 +13590,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIds
 
 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
 }
@@ -12197,7 +13626,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDec
 
 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -12231,7 +13662,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDec
 
 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -12265,7 +13698,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilte
 
 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
 }
@@ -12288,7 +13723,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
        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);
@@ -12297,7 +13734,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
 }
@@ -12310,7 +13749,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
-       LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKFilter o_conv = *(LDKFilter*)(o_ptr);
        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;
@@ -12326,7 +13767,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
        FREE((void*)_res);
        COption_FilterZ_free(_res_conv);
 }
@@ -12349,7 +13792,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitor
 
 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_LockedChannelMonitorNoneZ_free(_res_conv);
 }
@@ -12374,7 +13819,9 @@ void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArra
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentPurpose_free(this_ptr_conv);
 }
@@ -12412,7 +13859,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_p
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ClosureReason_free(this_ptr_conv);
 }
@@ -12487,7 +13936,9 @@ int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint3
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Event_free(this_ptr_conv);
 }
@@ -12518,7 +13969,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
+       CHECK_ACCESS(purpose_ptr);
+       LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
        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);
@@ -12526,24 +13979,36 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage, int8_tArray payment_hash) {
+uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKThirtyTwoBytes payment_preimage_ref;
        CHECK(*((uint32_t*)payment_preimage) == 32);
        memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
        LDKThirtyTwoBytes payment_hash_ref;
        CHECK(*((uint32_t*)payment_hash) == 32);
        memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
+       void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
+       CHECK_ACCESS(fee_paid_msat_ptr);
+       LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
+       fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
+       *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-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, uint32_t short_channel_id) {
+uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path, uint32_t short_channel_id, uint32_t retry) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        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);
+       void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
+       CHECK_ACCESS(network_update_ptr);
+       LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
        network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
        LDKCVec_RouteHopZ path_constr;
        path_constr.datalen = *((uint32_t*)path);
@@ -12560,10 +14025,16 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(in
                path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
                path_constr.data[k] = path_conv_10_conv;
        }
-       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
+       void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
+       CHECK_ACCESS(short_channel_id_ptr);
+       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
        short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
+       LDKRouteParameters retry_conv;
+       retry_conv.inner = (void*)(retry & (~1));
+       retry_conv.is_owned = (retry & 1) || (retry == 0);
+       retry_conv = RouteParameters_clone(&retry_conv);
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
+       *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -12585,7 +14056,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint
        uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
        for (size_t b = 0; b < outputs_constr.datalen; b++) {
                uint32_t outputs_conv_27 = outputs_vals[b];
-               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
+               void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
+               CHECK_ACCESS(outputs_conv_27_ptr);
+               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
                outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
                outputs_constr.data[b] = outputs_conv_27_conv;
        }
@@ -12596,7 +14069,9 @@ 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);
+       void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
+       CHECK_ACCESS(fee_earned_msat_ptr);
+       LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
        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);
@@ -12608,7 +14083,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tA
        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);
+       void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
+       CHECK_ACCESS(reason_ptr);
+       LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
        reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
        *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
@@ -12642,7 +14119,9 @@ int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj)
 
 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEvent_free(this_ptr_conv);
 }
@@ -12864,7 +14343,9 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_erro
        LDKPublicKey node_id_ref;
        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);
+       void* action_ptr = (void*)(((uint64_t)action) & ~1);
+       CHECK_ACCESS(action_ptr);
+       LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
        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);
@@ -12916,28 +14397,36 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_
 
 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEventsProvider_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventsProvider_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventHandler_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        APIError_free(this_ptr_conv);
 }
@@ -13086,7 +14575,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
 
 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Logger_free(this_ptr_conv);
 }
@@ -13145,9 +14636,10 @@ void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_h
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13159,9 +14651,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13170,9 +14663,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13308,9 +14802,10 @@ void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13322,9 +14817,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13333,9 +14829,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13456,9 +14953,10 @@ void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_av
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
        LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13470,9 +14968,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13481,9 +14980,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
        LDKChannelConfig ret_var = ChannelConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13522,9 +15022,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_c
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13547,9 +15048,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13572,9 +15074,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_optio
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13621,9 +15124,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_
        channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
        channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
        LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13635,9 +15139,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13646,9 +15151,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t or
 
 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
        LDKUserConfig ret_var = UserConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13667,9 +15173,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t ori
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13679,9 +15186,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t ori
 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
        LDKNetwork network_conv = LDKNetwork_from_js(network);
        LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13693,9 +15201,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray bl
        CHECK(*((uint32_t*)block_hash) == 32);
        memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
        LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13737,21 +15246,27 @@ uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
 
 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Access_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Listen_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Confirm_free(this_ptr_conv);
 }
@@ -13774,14 +15289,18 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_perm
 
 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Watch_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Filter_free(this_ptr_conv);
 }
@@ -13817,9 +15336,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13871,9 +15391,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArra
        script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
        LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13885,9 +15406,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13904,7 +15426,9 @@ int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o
 
 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BroadcasterInterface_free(this_ptr_conv);
 }
@@ -13939,46 +15463,102 @@ jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32
 
 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        FeeEstimator_free(this_ptr_conv);
 }
 
-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);
-       FREE((void*)this_ptr);
-       Persist_free(this_ptr_conv);
-}
-
-void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
-       LDKLockedChannelMonitor this_obj_conv;
+void  __attribute__((visibility("default"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
+       LDKMonitorUpdateId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       LockedChannelMonitor_free(this_obj_conv);
+       MonitorUpdateId_free(this_obj_conv);
 }
 
-void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
-       LDKChainMonitor this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       ChainMonitor_free(this_obj_conv);
+uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone(uint32_t orig) {
+       LDKMonitorUpdateId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_hash(uint32_t o) {
+       LDKMonitorUpdateId o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = MonitorUpdateId_hash(&o_conv);
+       return ret_val;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
+       LDKMonitorUpdateId a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKMonitorUpdateId b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Persist_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
+       LDKLockedChannelMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockedChannelMonitor_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
+       LDKChainMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ChainMonitor_free(this_obj_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
-       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
+       void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
+       CHECK_ACCESS(chain_source_ptr);
+       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
        // 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);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
+       CHECK_ACCESS(feeest_ptr);
+       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
        LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14005,14 +15585,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claima
                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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = 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;
 }
@@ -14035,27 +15617,47 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monit
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 k = 0; k < ret_var.datalen; k++) {
                LDKOutPoint ret_conv_10_var = ret_var.data[k];
+               uint64_t ret_conv_10_ref = 0;
                CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
+               ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
                if (ret_conv_10_var.is_owned) {
                        ret_conv_10_ref |= 1;
                }
                ret_arr_ptr[k] = ret_conv_10_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
+       LDKChainMonitor this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorUpdateId completed_update_id_conv;
+       completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
+       completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
+       completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
+       LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+       *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
+       return (uint64_t)ret_conv;
+}
+
 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_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14064,7 +15666,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14073,7 +15675,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
+       LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
        *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14082,7 +15684,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvid
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14114,9 +15716,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14150,14 +15753,46 @@ void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t
        MonitorUpdateError_free(this_obj_conv);
 }
 
+jstring  __attribute__((visibility("default"))) TS_MonitorUpdateError_get_a(uint32_t this_ptr) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
+       jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_MonitorUpdateError_set_a(uint32_t this_ptr, jstring val) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr val_conv = str_ref_to_owned_c(val);
+       MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_new(jstring a_arg) {
+       LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
+       LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
        LDKMonitorUpdateError orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14166,7 +15801,9 @@ uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uin
 
 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MonitorEvent_free(this_ptr_conv);
 }
@@ -14201,6 +15838,37 @@ uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_c
        return ret_ref;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+       *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_failed(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_update_failed(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_MonitorEvent_write(uint32_t obj) {
+       LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
+       LDKCVec_u8Z ret_var = MonitorEvent_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_HTLCUpdate_free(uint32_t this_obj) {
        LDKHTLCUpdate this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -14213,9 +15881,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14244,7 +15913,9 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Balance_free(this_ptr_conv);
 }
@@ -14304,9 +15975,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14331,9 +16003,15 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_update_monito
        LDKChannelMonitorUpdate updates_conv;
        updates_conv.inner = (void*)(updates & (~1));
        updates_conv.is_owned = false;
-       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
+       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
+       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
        *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
        return (uint64_t)ret_conv;
@@ -14361,13 +16039,15 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outp
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
                *ret_conv_40_conv = ret_var.data[o];
                ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14376,7 +16056,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_w
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
+       void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
+       if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
+       LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
        ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
 }
 
@@ -14385,14 +16067,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14402,14 +16086,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 h = 0; h < ret_var.datalen; h++) {
                LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
+               *ret_conv_7_copy = ret_var.data[h];
                uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
                ret_arr_ptr[h] = ret_conv_7_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14418,9 +16104,12 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_ho
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                LDKTransaction ret_conv_12_var = ret_var.data[m];
@@ -14429,6 +16118,7 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_ho
                Transaction_free(ret_conv_12_var);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14450,21 +16140,31 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_block_co
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14477,9 +16177,15 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnecte
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
 }
 
@@ -14500,21 +16206,31 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_transact
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14527,9 +16243,15 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_transaction_uncon
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
        unsigned char (*txid_ref)[32] = &txid_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
 }
 
@@ -14541,17 +16263,25 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_best_blo
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14561,13 +16291,15 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14577,9 +16309,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14591,14 +16324,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_clai
        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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = 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;
 }
@@ -14607,7 +16342,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMoni
        LDKu8slice ser_ref;
        ser_ref.datalen = *((uint32_t*)ser);
        ser_ref.data = (int8_t*)(ser + 4);
-       LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
+       void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
+       if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
+       LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
        return (uint64_t)ret_conv;
@@ -14659,9 +16396,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txi
        CHECK(*((uint32_t*)txid_arg) == 32);
        memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
        LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14673,9 +16411,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14742,9 +16481,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14800,7 +16540,9 @@ void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_s
        LDKDelayedPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -14866,7 +16608,9 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        LDKPublicKey per_commitment_point_arg_ref;
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
        LDKPublicKey revocation_pubkey_arg_ref;
        CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
@@ -14875,9 +16619,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
        memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14889,9 +16634,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14930,9 +16676,10 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14954,7 +16701,9 @@ void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_se
        LDKStaticPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -14998,15 +16747,18 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        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);
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15018,9 +16770,10 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15049,7 +16802,9 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
 
 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SpendableOutputDescriptor_free(this_ptr_conv);
 }
@@ -15067,7 +16822,9 @@ uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_st
        outpoint_conv.inner = (void*)(outpoint & (~1));
        outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
        outpoint_conv = OutPoint_clone(&outpoint_conv);
-       LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
+       void* output_ptr = (void*)(((uint64_t)output) & ~1);
+       CHECK_ACCESS(output_ptr);
+       LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
        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);
@@ -15117,28 +16874,36 @@ uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_re
 
 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BaseSign_free(this_ptr_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
-       LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSign* orig_conv = (LDKSign*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Sign_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        KeysInterface_free(this_ptr_conv);
 }
@@ -15269,9 +17034,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15301,9 +17067,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_new(int8_tArr
        CHECK(*((uint32_t*)channel_keys_id) == 32);
        memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
        LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15315,9 +17082,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15353,9 +17121,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15367,9 +17136,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_p
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15414,7 +17184,7 @@ 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_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+       LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
        *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -15423,7 +17193,7 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint3
        LDKInMemorySigner this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -15461,9 +17231,10 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray
        memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
        unsigned char (*seed_ref)[32] = &seed_arr;
        LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15479,9 +17250,10 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_k
        memcpy(params_arr, (uint8_t*)(params + 4), 32);
        unsigned char (*params_ref)[32] = &params_arr;
        LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15501,7 +17273,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_
        uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
        for (size_t b = 0; b < descriptors_constr.datalen; b++) {
                uint32_t descriptors_conv_27 = descriptors_vals[b];
-               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
+               void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
+               CHECK_ACCESS(descriptors_conv_27_ptr);
+               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
                descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
                descriptors_constr.data[b] = descriptors_conv_27_conv;
        }
@@ -15514,7 +17288,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_
        uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
        for (size_t h = 0; h < outputs_constr.datalen; h++) {
                uint32_t outputs_conv_7 = outputs_vals[h];
-               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
+               void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
+               CHECK_ACCESS(outputs_conv_7_ptr);
+               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
                outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
                outputs_constr.data[h] = outputs_conv_7_conv;
        }
@@ -15531,71 +17307,11 @@ 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_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+       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_PaymentId_free(uint32_t this_obj) {
-       LDKPaymentId this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       PaymentId_free(this_obj_conv);
-}
-
-int64_t  __attribute__((visibility("default"))) TS_PaymentId_hash(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = false;
-       int64_t ret_val = PaymentId_hash(&o_conv);
-       return ret_val;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_PaymentId_clone(uint32_t orig) {
-       LDKPaymentId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKPaymentId ret_var = PaymentId_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;
-}
-
-jboolean  __attribute__((visibility("default"))) TS_PaymentId_eq(uint32_t a, uint32_t b) {
-       LDKPaymentId a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = false;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = false;
-       jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
-       return ret_val;
-}
-
-int8_tArray  __attribute__((visibility("default"))) TS_PaymentId_write(uint32_t obj) {
-       LDKPaymentId obj_conv;
-       obj_conv.inner = (void*)(obj & (~1));
-       obj_conv.is_owned = false;
-       LDKCVec_u8Z ret_var = PaymentId_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_PaymentId_read(int8_tArray ser) {
-       LDKu8slice ser_ref;
-       ser_ref.datalen = *((uint32_t*)ser);
-       ser_ref.data = (int8_t*)(ser + 4);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = PaymentId_read(ser_ref);
-       return (uint64_t)ret_conv;
-}
-
 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
        LDKChannelManager this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -15631,9 +17347,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_blo
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15658,9 +17375,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t
        best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
        best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
        LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15672,9 +17390,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15735,9 +17454,10 @@ void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_c
 
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15749,9 +17469,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15789,9 +17510,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_feat
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15829,11 +17551,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forw
        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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -15862,9 +17587,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15876,9 +17602,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(ui
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15916,9 +17643,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterpa
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15941,11 +17669,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -15975,7 +17706,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
 }
@@ -16009,7 +17742,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_p
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
 }
@@ -16073,7 +17808,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
 }
@@ -16092,7 +17829,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_s
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
        val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
 }
@@ -16169,17 +17908,26 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArr
        funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
        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);
+       void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
+       CHECK_ACCESS(short_channel_id_arg_ptr);
+       LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
        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);
+       void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
+       CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
+       LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
+       void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
+       CHECK_ACCESS(confirmations_required_arg_ptr);
+       LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
        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);
+       void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
+       CHECK_ACCESS(force_close_spend_delay_arg_ptr);
+       LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
        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_channel_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16191,9 +17939,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16202,7 +17951,9 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_
 
 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentSendFailure_free(this_ptr_conv);
 }
@@ -16216,7 +17967,9 @@ 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);
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
        a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
        *ret_copy = PaymentSendFailure_parameter_error(a_conv);
@@ -16234,7 +17987,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_para
        uint32_t* a_vals = (uint32_t*)(a + 4);
        for (size_t w = 0; w < a_constr.datalen; w++) {
                uint32_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
+               void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
+               CHECK_ACCESS(a_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
                a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
                a_constr.data[w] = a_conv_22_conv;
        }
@@ -16254,7 +18009,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_faile
        uint32_t* a_vals = (uint32_t*)(a + 4);
        for (size_t k = 0; k < a_constr.datalen; k++) {
                uint32_t a_conv_10 = a_vals[k];
-               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
+               void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
+               CHECK_ACCESS(a_conv_10_ptr);
+               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
                a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
                a_constr.data[k] = a_conv_10_conv;
        }
@@ -16264,32 +18021,50 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_faile
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
-       LDKCVec_CResult_NoneAPIErrorZZ a_constr;
-       a_constr.datalen = *((uint32_t*)a);
-       if (a_constr.datalen > 0)
-               a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
+uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
+       LDKCVec_CResult_NoneAPIErrorZZ results_constr;
+       results_constr.datalen = *((uint32_t*)results);
+       if (results_constr.datalen > 0)
+               results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
        else
-               a_constr.data = NULL;
-       uint32_t* a_vals = (uint32_t*)(a + 4);
-       for (size_t w = 0; w < a_constr.datalen; w++) {
-               uint32_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
-               a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
-               a_constr.data[w] = a_conv_22_conv;
-       }
+               results_constr.data = NULL;
+       uint32_t* results_vals = (uint32_t*)(results + 4);
+       for (size_t w = 0; w < results_constr.datalen; w++) {
+               uint32_t results_conv_22 = results_vals[w];
+               void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
+               CHECK_ACCESS(results_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
+               results_constr.data[w] = results_conv_22_conv;
+       }
+       LDKRouteParameters failed_paths_retry_conv;
+       failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
+       failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
+       failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
-       *ret_copy = PaymentSendFailure_partial_failure(a_constr);
+       *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) {
-       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
+       CHECK_ACCESS(fee_est_ptr);
+       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKUserConfig config_conv;
        config_conv.inner = (void*)(config & (~1));
        config_conv.is_owned = (config & 1) || (config == 0);
@@ -16299,9 +18074,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t
        params_conv.is_owned = (params & 1) || (params == 0);
        params_conv = ChainParameters_clone(&params_conv);
        LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16313,9 +18089,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_d
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16343,18 +18120,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_cha
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -16364,18 +18144,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -16444,19 +18227,18 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, uint32_t payment_id) {
+uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRoute route_conv;
        route_conv.inner = (void*)(route & (~1));
        route_conv.is_owned = false;
-       LDKPaymentId payment_id_conv;
-       payment_id_conv.inner = (void*)(payment_id & (~1));
-       payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
-       payment_id_conv = PaymentId_clone(&payment_id_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
-       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
+       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
        return (uint64_t)ret_conv;
 }
 
@@ -16512,7 +18294,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_an
        uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
        for (size_t m = 0; m < addresses_constr.datalen; m++) {
                uint32_t addresses_conv_12 = addresses_vals[m];
-               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
+               void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
+               CHECK_ACCESS(addresses_conv_12_ptr);
+               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
                addresses_constr.data[m] = addresses_conv_12_conv;
        }
        ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
@@ -16564,21 +18348,13 @@ int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_no
        return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
-       LDKChannelManager this_arg_conv;
-       this_arg_conv.inner = (void*)(this_arg & (~1));
-       this_arg_conv.is_owned = false;
-       LDKOutPoint funding_txo_conv;
-       funding_txo_conv.inner = (void*)(funding_txo & (~1));
-       funding_txo_conv.is_owned = false;
-       ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
        LDKChannelManager this_arg_conv;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
        LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
        *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
@@ -16592,7 +18368,9 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inboun
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        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);
@@ -16603,7 +18381,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16612,7 +18390,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProv
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16621,7 +18399,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uin
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16630,7 +18408,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(ui
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16655,9 +18433,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16668,7 +18447,7 @@ 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_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16695,7 +18474,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_k
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16703,7 +18483,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
        ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
 }
 
@@ -16711,7 +18493,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_f
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16719,7 +18502,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_e
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
        ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
 }
 
@@ -16727,7 +18512,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_c
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16735,7 +18521,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKWatch val_conv = *(LDKWatch*)(val_ptr);
        ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
 }
 
@@ -16743,7 +18531,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_t
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16751,7 +18540,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_br
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
        ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
 }
 
@@ -16759,7 +18550,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_l
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16767,7 +18559,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logge
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKLogger val_conv = *(LDKLogger*)(val_ptr);
        ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
 }
 
@@ -16776,9 +18570,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_d
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16797,11 +18592,21 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_defau
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKUserConfig default_config_conv;
        default_config_conv.inner = (void*)(default_config & (~1));
        default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
@@ -16821,9 +18626,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(u
                channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
        }
        LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16855,9 +18661,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16876,9 +18683,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16902,9 +18710,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_a
        features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
        features_arg_conv = InitFeatures_clone(&features_arg_conv);
        LDKInit ret_var = Init_new(features_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16916,9 +18725,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInit ret_var = Init_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16975,9 +18785,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray
        memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
        LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
        LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16989,9 +18800,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17037,9 +18849,10 @@ void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_
 
 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
        LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17051,9 +18864,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPing ret_var = Ping_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17084,9 +18898,10 @@ void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_
 
 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
        LDKPong ret_var = Pong_new(byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17098,9 +18913,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPong ret_var = Pong_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17421,9 +19237,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17680,9 +19497,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17779,9 +19597,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArr
        CHECK(*((uint32_t*)signature_arg) == 64);
        memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
        LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17793,9 +19612,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17855,9 +19675,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArra
        CHECK(*((uint32_t*)signature_arg) == 64);
        memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
        LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17869,9 +19690,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17931,9 +19753,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArra
        CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
        memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
        LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17945,9 +19768,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18010,9 +19834,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray cha
        scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
        LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18024,9 +19849,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdown ret_var = Shutdown_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18072,9 +19898,10 @@ void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fe
 
 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18086,9 +19913,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18160,11 +19988,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -18192,9 +20023,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArra
        fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
        fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
        LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18206,9 +20038,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18310,9 +20143,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18387,9 +20221,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_t
        CHECK(*((uint32_t*)payment_preimage_arg) == 32);
        memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18401,9 +20236,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18456,9 +20292,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18526,9 +20363,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18623,9 +20461,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tA
                htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
        }
        LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18637,9 +20476,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18721,9 +20561,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray
        CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
        memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
        LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18735,9 +20576,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18790,9 +20632,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray ch
        CHECK(*((uint32_t*)channel_id_arg) == 32);
        memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
        LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18804,9 +20647,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t ori
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18866,9 +20710,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tAr
        CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
        memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
        LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18880,9 +20725,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18950,9 +20796,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uin
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19049,9 +20896,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(i
        CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
        memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19063,9 +20911,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19074,7 +20923,9 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone
 
 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetAddress_free(this_ptr_conv);
 }
@@ -19136,15 +20987,6 @@ int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t
        return ret_arr;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
-       LDKu8slice ser_ref;
-       ser_ref.datalen = *((uint32_t*)ser);
-       ser_ref.data = (int8_t*)(ser + 4);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = Result_read(ser_ref);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
        LDKu8slice ser_ref;
        ser_ref.datalen = *((uint32_t*)ser);
@@ -19166,9 +21008,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19271,7 +21114,9 @@ void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_add
        uint32_t* val_vals = (uint32_t*)(val + 4);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                uint32_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -19283,9 +21128,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19323,9 +21169,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_content
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19352,9 +21199,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tA
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
        LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19366,9 +21214,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19387,9 +21236,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19522,9 +21372,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19619,9 +21470,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_cont
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19657,9 +21509,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_new(int8
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19671,9 +21524,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(ui
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19816,9 +21670,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19856,9 +21711,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19885,9 +21741,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArra
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
        LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19899,9 +21756,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19969,9 +21827,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_t
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19983,9 +21842,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20097,9 +21957,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_new(int8_t
                short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
        }
        LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20111,9 +21972,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20180,9 +22042,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int
                short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
        }
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20194,9 +22057,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20249,9 +22113,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20263,9 +22128,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20333,9 +22199,10 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(in
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20347,9 +22214,10 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20358,7 +22226,9 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(
 
 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ErrorAction_free(this_ptr_conv);
 }
@@ -20447,19 +22317,24 @@ void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32
        LDKLightningError this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
        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);
+       void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
+       CHECK_ACCESS(action_arg_ptr);
+       LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
        action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
        LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20471,9 +22346,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKLightningError ret_var = LightningError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20492,18 +22368,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_15_ref = 0;
                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;
+               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;
 }
@@ -20535,18 +22414,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_19_ref = 0;
                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;
+               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;
 }
@@ -20578,18 +22460,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -20621,18 +22506,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_25_ref = 0;
                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;
+               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;
 }
@@ -20664,11 +22552,14 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -20689,9 +22580,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitm
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20779,9 +22671,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_new(uint32_
        commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
        commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
        LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20793,9 +22686,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20804,14 +22698,18 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ChannelMessageHandler_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        RoutingMessageHandler_free(this_ptr_conv);
 }
@@ -21466,7 +23364,9 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(i
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        CustomMessageHandler_free(this_ptr_conv);
 }
@@ -21480,9 +23380,10 @@ void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint
 
 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
        LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21493,7 +23394,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21502,7 +23403,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Ro
        LDKIgnoringMessageHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21511,7 +23412,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Cu
        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");
+       LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21520,7 +23421,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Cu
        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");
+       LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21534,9 +23435,10 @@ void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint
 
 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
        LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21547,7 +23449,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21556,7 +23458,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_Ch
        LDKErroringMessageHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21572,7 +23474,8 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_hand
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -21580,7 +23483,9 @@ void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
        MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
 }
 
@@ -21588,7 +23493,8 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_han
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -21596,17 +23502,24 @@ void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
        MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
-       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
-       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
+       void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
+       CHECK_ACCESS(chan_handler_arg_ptr);
+       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
+       void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
+       CHECK_ACCESS(route_handler_arg_ptr);
+       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
        LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21614,15 +23527,19 @@ 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_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SocketDescriptor_free(this_ptr_conv);
 }
@@ -21651,9 +23568,10 @@ void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connectio
 
 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
        LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21665,9 +23583,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21693,12 +23612,17 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t mes
        CHECK(*((uint32_t*)ephemeral_random_data) == 32);
        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);
-       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
+       CHECK_ACCESS(custom_message_handler_ptr);
+       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
        LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21710,13 +23634,15 @@ ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_id
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -21728,7 +23654,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_con
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
        *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21738,7 +23666,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_conn
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21748,7 +23678,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_spa
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21758,7 +23690,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint3
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
+       void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
+       if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
+       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = *((uint32_t*)data);
        data_ref.data = (int8_t*)(data + 4);
@@ -21778,7 +23712,9 @@ void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
 }
 
@@ -21792,6 +23728,13 @@ void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_i
        PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
 }
 
+void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
+       LDKPeerManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       PeerManager_disconnect_all_peers(&this_arg_conv);
+}
+
 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -21999,9 +23942,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_new(int8_tArr
        CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
        memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
        LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22013,9 +23957,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22161,9 +24106,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_new(int8_t
        CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
        memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22175,9 +24121,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22339,7 +24286,9 @@ void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_trans
        LDKHTLCOutputInCommitment this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
 }
@@ -22348,12 +24297,15 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(j
        LDKThirtyTwoBytes payment_hash_arg_ref;
        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);
+       void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
+       CHECK_ACCESS(transaction_output_index_arg_ptr);
+       LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22365,9 +24317,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22455,9 +24408,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22510,11 +24464,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -22535,11 +24492,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -22569,9 +24529,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
        funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22583,9 +24544,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22604,9 +24566,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22645,9 +24608,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
        pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22659,9 +24623,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22681,9 +24646,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22695,9 +24661,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22756,9 +24723,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22770,9 +24738,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22800,9 +24769,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22861,9 +24831,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22919,9 +24890,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_
        CHECK(*((uint32_t*)counterparty_funding_key) == 33);
        memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22987,9 +24959,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_n
        CHECK(*((uint32_t*)txid_arg) == 32);
        memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23001,9 +24974,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23065,6 +25039,29 @@ void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t
        ClosingTransaction_free(this_obj_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone(uint32_t orig) {
+       LDKClosingTransaction orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_hash(uint32_t o) {
+       LDKClosingTransaction o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = ClosingTransaction_hash(&o_conv);
+       return ret_val;
+}
+
 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);
@@ -23079,9 +25076,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23093,9 +25091,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23209,9 +25208,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23275,9 +25275,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23323,9 +25324,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23337,9 +25339,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23422,9 +25425,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23436,9 +25440,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23450,9 +25455,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23464,9 +25470,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23503,9 +25510,10 @@ void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t th
 
 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
        LDKInitFeatures ret_var = InitFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23514,9 +25522,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
        LDKInitFeatures ret_var = InitFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23533,9 +25542,10 @@ jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknow
 
 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
        LDKNodeFeatures ret_var = NodeFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23544,9 +25554,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
        LDKNodeFeatures ret_var = NodeFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23563,9 +25574,10 @@ jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknow
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
        LDKChannelFeatures ret_var = ChannelFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23574,9 +25586,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
        LDKChannelFeatures ret_var = ChannelFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23593,9 +25606,10 @@ jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unk
 
 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23604,9 +25618,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23737,9 +25752,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23780,9 +25796,25 @@ uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(in
        script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
        LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
+       LDKInvalidShutdownScript orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23815,9 +25847,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(in
        memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
        unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23830,9 +25863,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int
        memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
        unsigned char (*script_hash_ref)[32] = &script_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23882,65 +25916,108 @@ jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
        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");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKType* orig_conv = (LDKType*)orig_ptr;
+       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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Type_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Score_free(this_ptr_conv);
 }
 
-void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
-       LDKNodeId this_obj_conv;
+void  __attribute__((visibility("default"))) TS_LockableScore_free(uint32_t this_obj) {
+       LDKLockableScore this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       NodeId_free(this_obj_conv);
+       LockableScore_free(this_obj_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
-       LDKNodeId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKNodeId ret_var = NodeId_clone(&orig_conv);
+uint32_t  __attribute__((visibility("default"))) TS_LockableScore_new(uint32_t score) {
+       void* score_ptr = (void*)(((uint64_t)score) & ~1);
+       CHECK_ACCESS(score_ptr);
+       LDKScore score_conv = *(LDKScore*)(score_ptr);
+       LDKLockableScore ret_var = LockableScore_new(score_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
-       LDKPublicKey pubkey_ref;
-       CHECK(*((uint32_t*)pubkey) == 33);
-       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
-       LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
-       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;
+int8_tArray  __attribute__((visibility("default"))) TS_LockableScore_write(uint32_t obj) {
+       LDKLockableScore obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = LockableScore_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_NodeId_free(uint32_t this_obj) {
+       LDKNodeId this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       NodeId_free(this_obj_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
+       LDKNodeId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKNodeId ret_var = NodeId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
@@ -23993,9 +26070,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24011,7 +26089,9 @@ void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetworkUpdate_free(this_ptr_conv);
 }
@@ -24065,7 +26145,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventH
        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");
+       LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24077,46 +26157,25 @@ void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t
        NetGraphMsgHandler_free(this_obj_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;
-       if (ret_var.is_owned) {
-               ret_ref |= 1;
-       }
-       return ret_ref;
-}
-
-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);
-       val_conv = NetworkGraph_clone(&val_conv);
-       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);
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       network_graph_conv.is_owned = false;
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24127,7 +26186,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -24139,7 +26200,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_Routin
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24148,7 +26209,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_Messag
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24234,7 +26295,9 @@ void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_
        LDKDirectionalChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -24244,9 +26307,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_f
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24269,11 +26333,14 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_l
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24290,7 +26357,9 @@ 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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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));
@@ -24301,9 +26370,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(i
        last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
        last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24315,9 +26385,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24356,9 +26427,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24381,9 +26453,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24406,11 +26479,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24431,9 +26507,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24456,11 +26533,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24490,7 +26570,9 @@ void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(ui
        LDKChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
 }
@@ -24500,11 +26582,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24541,16 +26626,19 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t fea
        two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
        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);
+       void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
+       CHECK_ACCESS(capacity_sats_arg_ptr);
+       LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
        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);
        announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
        LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24562,9 +26650,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24630,9 +26719,10 @@ void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_mil
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
        LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24655,9 +26745,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24704,9 +26795,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_fea
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24790,7 +26882,9 @@ void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_address
        uint32_t* val_vals = (uint32_t*)(val + 4);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                uint32_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -24802,11 +26896,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_ann
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24842,7 +26939,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uin
        uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
        for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
                uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
-               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               CHECK_ACCESS(addresses_arg_conv_12_ptr);
+               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
                addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
        }
        LDKNodeAnnouncement announcement_message_arg_conv;
@@ -24850,9 +26949,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uin
        announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
        announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24864,9 +26964,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24923,11 +27024,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24948,11 +27052,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_in
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24989,9 +27096,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray ch
        announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
        announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
        LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25003,9 +27111,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25057,9 +27166,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray
        CHECK(*((uint32_t*)genesis_hash) == 32);
        memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
        LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25071,9 +27181,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25111,7 +27222,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -25128,7 +27241,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -25223,9 +27338,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25263,9 +27379,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_feature
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25326,9 +27443,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_new(int8_tArray pub
        channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
        channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
        LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25340,9 +27458,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25400,25 +27519,30 @@ ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t thi
        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");
+       ptrArray ret_arr = NULL;
+       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_tArray ret_conv_12_arr = NULL;
+               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];
+                       uint64_t ret_conv_12_conv_10_ref = 0;
                        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;
+                       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;
 }
@@ -25456,7 +27580,35 @@ void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_pt
        Route_set_paths(&this_ptr_conv, val_constr);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
+uint32_t  __attribute__((visibility("default"))) TS_Route_get_payee(uint32_t this_ptr) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       Route_set_payee(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
        LDKCVec_CVec_RouteHopZZ paths_arg_constr;
        paths_arg_constr.datalen = *((uint32_t*)paths_arg);
        if (paths_arg_constr.datalen > 0)
@@ -25483,10 +27635,15 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg
                }
                paths_arg_constr.data[m] = paths_arg_conv_12_constr;
        }
-       LDKRoute ret_var = Route_new(paths_arg_constr);
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25498,9 +27655,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoute ret_var = Route_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25562,161 +27720,617 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser)
        return (uint64_t)ret_conv;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
-       LDKRouteHint this_obj_conv;
+void  __attribute__((visibility("default"))) TS_RouteParameters_free(uint32_t this_obj) {
+       LDKRouteParameters this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       RouteHint_free(this_obj_conv);
+       RouteParameters_free(this_obj_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
-       LDKRouteHint orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
        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;
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       RouteParameters_set_payee(&this_ptr_conv, val_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);
+int64_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_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));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       RouteHintHop_free(this_obj_conv);
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_value_msat(&this_ptr_conv, val);
 }
 
-int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+int32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
+       LDKRouteParameters 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), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
-       return ret_arr;
+       int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
+       LDKRouteParameters 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);
-       RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
+       RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
 }
 
-int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_clone(uint32_t orig) {
+       LDKRouteParameters orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteParameters_write(uint32_t obj) {
+       LDKRouteParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteParameters_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_RouteParameters_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = RouteParameters_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_Payee_free(uint32_t this_obj) {
+       LDKPayee this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Payee_free(this_obj_conv);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
-       return ret_val;
+       int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
+       LDKPublicKey val_ref;
+       CHECK(*((uint32_t*)val) == 33);
+       memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
+       Payee_set_pubkey(&this_ptr_conv, val_ref);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_get_features(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingFees ret_var = RouteHintHop_get_fees(&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;
+       LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingFees val_conv;
+       LDKInvoiceFeatures val_conv;
        val_conv.inner = (void*)(val & (~1));
        val_conv.is_owned = (val & 1) || (val == 0);
-       val_conv = RoutingFees_clone(&val_conv);
-       RouteHintHop_set_fees(&this_ptr_conv, val_conv);
+       val_conv = InvoiceFeatures_clone(&val_conv);
+       Payee_set_features(&this_ptr_conv, val_conv);
 }
 
-int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_tArray  __attribute__((visibility("default"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
-       return ret_val;
+       LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
+       uint32_tArray ret_arr = NULL;
+       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 l = 0; l < ret_var.datalen; l++) {
+               LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
+               CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               if (ret_conv_11_var.is_owned) {
+                       ret_conv_11_ref |= 1;
+               }
+               ret_arr_ptr[l] = ret_conv_11_ref;
+       }
+       
+       FREE(ret_var.data);
+       return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
+       LDKCVec_RouteHintZ val_constr;
+       val_constr.datalen = *((uint32_t*)val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               val_constr.data = NULL;
+       uint32_t* val_vals = (uint32_t*)(val + 4);
+       for (size_t l = 0; l < val_constr.datalen; l++) {
+               uint32_t val_conv_11 = val_vals[l];
+               LDKRouteHint val_conv_11_conv;
+               val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
+               val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
+               val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
+               val_constr.data[l] = val_conv_11_conv;
+       }
+       Payee_set_route_hints(&this_ptr_conv, val_constr);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
+       *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
-       RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
+       Payee_set_expiry_time(&this_ptr_conv, val_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
-       this_ptr_conv.inner = (void*)(this_ptr & (~1));
-       this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
+       LDKPublicKey pubkey_arg_ref;
+       CHECK(*((uint32_t*)pubkey_arg) == 33);
+       memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
+       LDKInvoiceFeatures 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 = InvoiceFeatures_clone(&features_arg_conv);
+       LDKCVec_RouteHintZ route_hints_arg_constr;
+       route_hints_arg_constr.datalen = *((uint32_t*)route_hints_arg);
+       if (route_hints_arg_constr.datalen > 0)
+               route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               route_hints_arg_constr.data = NULL;
+       uint32_t* route_hints_arg_vals = (uint32_t*)(route_hints_arg + 4);
+       for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
+               uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
+               LDKRouteHint route_hints_arg_conv_11_conv;
+               route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
+               route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
+               route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
+               route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
+       }
+       void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
+       CHECK_ACCESS(expiry_time_arg_ptr);
+       LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
+       expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
+       LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_clone(uint32_t orig) {
+       LDKPayee orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKPayee ret_var = Payee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_Payee_hash(uint32_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = Payee_hash(&o_conv);
+       return ret_val;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_Payee_eq(uint32_t a, uint32_t b) {
+       LDKPayee a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKPayee b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = Payee_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Payee_write(uint32_t obj) {
+       LDKPayee obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Payee_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_Payee_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = Payee_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_from_node_id(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_for_keysend(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
+       LDKRouteHint this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteHint_free(this_obj_conv);
+}
+
+uint32_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_a(uint32_t this_ptr) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
+               LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
+               CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               if (ret_conv_14_var.is_owned) {
+                       ret_conv_14_ref |= 1;
+               }
+               ret_arr_ptr[o] = ret_conv_14_ref;
+       }
+       
+       FREE(ret_var.data);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ val_constr;
+       val_constr.datalen = *((uint32_t*)val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               val_constr.data = NULL;
+       uint32_t* val_vals = (uint32_t*)(val + 4);
+       for (size_t o = 0; o < val_constr.datalen; o++) {
+               uint32_t val_conv_14 = val_vals[o];
+               LDKRouteHintHop val_conv_14_conv;
+               val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
+               val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
+               val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
+               val_constr.data[o] = val_conv_14_conv;
+       }
+       RouteHint_set_a(&this_ptr_conv, val_constr);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(uint32_tArray a_arg) {
+       LDKCVec_RouteHintHopZ a_arg_constr;
+       a_arg_constr.datalen = *((uint32_t*)a_arg);
+       if (a_arg_constr.datalen > 0)
+               a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               a_arg_constr.data = NULL;
+       uint32_t* a_arg_vals = (uint32_t*)(a_arg + 4);
+       for (size_t o = 0; o < a_arg_constr.datalen; o++) {
+               uint32_t a_arg_conv_14 = a_arg_vals[o];
+               LDKRouteHintHop a_arg_conv_14_conv;
+               a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
+               a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
+               a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
+               a_arg_constr.data[o] = a_arg_conv_14_conv;
+       }
+       LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
+       LDKRouteHint orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       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;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_write(uint32_t obj) {
+       LDKRouteHint obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHint_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_RouteHint_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = RouteHint_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
+       LDKRouteHintHop this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteHintHop_free(this_obj_conv);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
+       LDKRouteHintHop 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), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
+       LDKRouteHintHop 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);
+       RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKRoutingFees val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = RoutingFees_clone(&val_conv);
+       RouteHintHop_set_fees(&this_ptr_conv, val_conv);
+}
+
+int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
+       val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
+       RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
 }
 
 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -25729,14 +28343,19 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray
        fees_arg_conv.inner = (void*)(fees_arg & (~1));
        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);
+       void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
        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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25748,9 +28367,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25776,71 +28396,36 @@ jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a,
        return ret_val;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_pubkey, 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, uint32_t scorer) {
-       LDKPublicKey our_node_pubkey_ref;
-       CHECK(*((uint32_t*)our_node_pubkey) == 33);
-       memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
-       LDKNetworkGraph network_conv;
-       network_conv.inner = (void*)(network & (~1));
-       network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK(*((uint32_t*)payee) == 33);
-       memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
-       LDKCVec_ChannelDetailsZ first_hops_constr;
-       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
-       if (first_hops != 0) {
-               first_hops_constr.datalen = *((uint32_t*)first_hops);
-               if (first_hops_constr.datalen > 0)
-                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-               else
-                       first_hops_constr.data = NULL;
-               uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
-               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
-                       uint32_t first_hops_conv_16 = first_hops_vals[q];
-                       LDKChannelDetails first_hops_conv_16_conv;
-                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
-                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
-                       first_hops_constr.data[q] = first_hops_conv_16_conv;
-               }
-               first_hops_ptr = &first_hops_constr;
-       }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = *((uint32_t*)last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               uint32_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
-       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
-       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_write(uint32_t obj) {
+       LDKRouteHintHop obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHintHop_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_RouteHintHop_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = RouteHintHop_read(ser_ref);
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_pubkey, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger, uint32_t scorer) {
+uint32_t  __attribute__((visibility("default"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
        LDKPublicKey our_node_pubkey_ref;
        CHECK(*((uint32_t*)our_node_pubkey) == 33);
        memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
        LDKNetworkGraph network_conv;
        network_conv.inner = (void*)(network & (~1));
        network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK(*((uint32_t*)payee) == 33);
-       memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
-       LDKInvoiceFeatures payee_features_conv;
-       payee_features_conv.inner = (void*)(payee_features & (~1));
-       payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
-       payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
        LDKCVec_ChannelDetailsZ first_hops_constr;
        LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
        if (first_hops != 0) {
@@ -25859,41 +28444,119 @@ uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_no
                }
                first_hops_ptr = &first_hops_constr;
        }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = *((uint32_t*)last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               uint32_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
+       *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
        if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
        return (uint64_t)ret_conv;
 }
 
-void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
-       LDKScorer this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       Scorer_free(this_obj_conv);
+void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
+       LDKScorer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Scorer_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_free(uint32_t this_obj) {
+       LDKScoringParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ScoringParameters_free(this_obj_conv);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
+       LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_ScoringParameters_write(uint32_t obj) {
+       LDKScoringParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = ScoringParameters_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_ScoringParameters_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = ScoringParameters_read(ser_ref);
+       return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(int64_t base_penalty_msat) {
-       LDKScorer ret_var = Scorer_new(base_penalty_msat);
+uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(uint32_t params) {
+       LDKScoringParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = (params & 1) || (params == 0);
+       // Warning: we need a move here but no clone is available for LDKScoringParameters
+       LDKScorer ret_var = Scorer_new(params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25902,9 +28565,22 @@ uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(int64_t base_pena
 
 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
        LDKScorer ret_var = Scorer_default();
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_default() {
+       LDKScoringParameters ret_var = ScoringParameters_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25915,11 +28591,31 @@ uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t thi
        LDKScorer this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
+       LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
        *ret_ret = Scorer_as_Score(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
 
+int8_tArray  __attribute__((visibility("default"))) TS_Scorer_write(uint32_t obj) {
+       LDKScorer obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Scorer_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_Scorer_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = Scorer_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
        LDKFilesystemPersister this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -25930,9 +28626,10 @@ void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_
 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
        LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
        LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25963,7 +28660,9 @@ uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_cha
        LDKFilesystemPersister this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
        *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
        return (uint64_t)ret_conv;
@@ -25973,7 +28672,7 @@ 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_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
+       LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
        *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -25987,14 +28686,20 @@ void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_
 
 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        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 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);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
        LDKChainMonitor chain_monitor_conv;
        chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
        chain_monitor_conv.is_owned = false;
@@ -26007,11 +28712,14 @@ uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(ui
        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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26065,9 +28773,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig)
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoice ret_var = Invoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26097,9 +28806,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26118,9 +28828,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26154,9 +28865,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26175,9 +28887,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(ui
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26211,9 +28924,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26243,9 +28957,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26347,9 +29062,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig)
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSha256 ret_var = Sha256_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26387,9 +29103,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDescription ret_var = Description_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26422,14 +29139,49 @@ void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_o
        PayeePubKey_free(this_obj_conv);
 }
 
+int8_tArray  __attribute__((visibility("default"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
+       LDKPayeePubKey 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), PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
+       LDKPayeePubKey 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);
+       PayeePubKey_set_a(&this_ptr_conv, val_ref);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_new(int8_tArray a_arg) {
+       LDKPublicKey a_arg_ref;
+       CHECK(*((uint32_t*)a_arg) == 33);
+       memcpy(a_arg_ref.compressed_form, (uint8_t*)(a_arg + 4), 33);
+       LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 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;
        LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26467,9 +29219,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26502,14 +29255,42 @@ void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t
        MinFinalCltvExpiry_free(this_obj_conv);
 }
 
+int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
+       LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26537,7 +29318,9 @@ jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Fallback_free(this_ptr_conv);
 }
@@ -26607,9 +29390,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26639,9 +29423,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26682,9 +29467,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26705,9 +29491,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(u
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26745,11 +29532,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_payment_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26759,11 +29549,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDescription ret_var = RawInvoice_description(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26773,11 +29566,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26787,11 +29583,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_description_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26801,11 +29600,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKExpiryTime ret_var = RawInvoice_expiry_time(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26815,11 +29617,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_ex
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26838,11 +29643,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = RawInvoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26852,18 +29660,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_rout
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -26920,9 +29731,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = Invoice_clone(&this_arg_conv);
        LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26979,7 +29791,7 @@ int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(ui
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
-       memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
+       memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_secret(&this_arg_conv), 32);
        return ret_arr;
 }
 
@@ -26988,11 +29800,14 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t th
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = Invoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27014,6 +29829,14 @@ int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t
        return ret_val;
 }
 
+jboolean  __attribute__((visibility("default"))) TS_Invoice_is_expired(uint32_t this_arg) {
+       LDKInvoice this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       jboolean ret_val = Invoice_is_expired(&this_arg_conv);
+       return ret_val;
+}
+
 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -27027,18 +29850,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -27048,18 +29874,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 l = 0; l < ret_var.datalen; l++) {
                LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
                CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
                if (ret_conv_11_var.is_owned) {
                        ret_conv_11_ref |= 1;
                }
                ret_arr_ptr[l] = ret_conv_11_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -27072,12 +29901,12 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t th
        return ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
+uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
+       *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -27144,9 +29973,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = PrivateRoute_clone(&this_arg_conv);
        LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27267,7 +30097,9 @@ jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t
 
 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SignOrCreationError_free(this_ptr_conv);
 }
@@ -27310,13 +30142,232 @@ jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(ui
        return ret_conv;
 }
 
+void  __attribute__((visibility("default"))) TS_InvoicePayer_free(uint32_t this_obj) {
+       LDKInvoicePayer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       InvoicePayer_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_Payer_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Payer_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_Router_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Router_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_RetryAttempts_free(uint32_t this_obj) {
+       LDKRetryAttempts this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RetryAttempts_free(this_obj_conv);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RetryAttempts_set_a(uint32_t this_ptr, int64_t val) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RetryAttempts_set_a(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_new(int64_t a_arg) {
+       LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone(uint32_t orig) {
+       LDKRetryAttempts orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
+       LDKRetryAttempts a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKRetryAttempts b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_hash(uint32_t o) {
+       LDKRetryAttempts o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_hash(&o_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_PaymentError_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       PaymentError_free(this_ptr_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_clone(uint32_t orig) {
+       LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_invoice(jstring a) {
+       LDKStr a_conv = str_ref_to_owned_c(a);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_invoice(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_routing(uint32_t a) {
+       LDKLightningError a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = (a & 1) || (a == 0);
+       a_conv = LightningError_clone(&a_conv);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_routing(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_sending(uint32_t a) {
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
+       a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_sending(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
+       void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
+       CHECK_ACCESS(payer_ptr);
+       LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
+       void* router_ptr = (void*)(((uint64_t)router) & ~1);
+       CHECK_ACCESS(router_ptr);
+       LDKRouter router_conv = *(LDKRouter*)(router_ptr);
+       LDKLockableScore scorer_conv;
+       scorer_conv.inner = (void*)(scorer & (~1));
+       scorer_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
+       LDKRetryAttempts retry_attempts_conv;
+       retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
+       retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
+       retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
+       LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       unsigned char payment_hash_arr[32];
+       CHECK(*((uint32_t*)payment_hash) == 32);
+       memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
+       unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
+       InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
+       LDKInvoicePayer 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 = InvoicePayer_as_EventHandler(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelmanager(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description) {
        LDKChannelManager channelmanager_conv;
        channelmanager_conv.inner = (void*)(channelmanager & (~1));
        channelmanager_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKCurrency network_conv = LDKCurrency_from_js(network);
-       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
+       void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
+       CHECK_ACCESS(amt_msat_ptr);
+       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
        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");
@@ -27324,6 +30375,49 @@ uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelm
        return (uint64_t)ret_conv;
 }
 
+void  __attribute__((visibility("default"))) TS_DefaultRouter_free(uint32_t this_obj) {
+       LDKDefaultRouter this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       DefaultRouter_free(this_obj_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
+       LDKNetworkGraph network_graph_conv;
+       network_graph_conv.inner = (void*)(network_graph & (~1));
+       network_graph_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
+       LDKDefaultRouter this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
+       LDKChannelManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
        LDKStr s_conv = str_ref_to_owned_c(s);
        LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
index c2e953afa383a8063f52209afaf7b80f64050023..b9a8cdc69b797f3ea488f9154b42af5bab344f39 100644 (file)
@@ -16,9 +16,10 @@ void *malloc(size_t size);
 void free(void *ptr);
 
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); }
+#define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
+#define CHECK_ACCESS(p)
 
 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
@@ -382,18 +383,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDec
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
@@ -403,18 +406,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeys
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelPublicKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
@@ -424,9 +429,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErr
        LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTxCreationKeys res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
@@ -454,18 +460,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommi
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCOutputInCommitment res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
@@ -475,18 +483,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChann
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
@@ -496,18 +506,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactio
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelTransactionParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
@@ -517,18 +529,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentT
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHolderCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
@@ -538,18 +552,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTr
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) {
@@ -559,9 +575,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTra
        LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedClosingTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
@@ -576,18 +593,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransac
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
@@ -597,9 +616,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitment
        LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
@@ -614,13 +634,15 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNo
        LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_SignatureZ res_var = (*val->contents.result);
-       ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
        for (size_t m = 0; m < res_var.datalen; m++) {
                int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
                res_arr_ptr[m] = res_conv_12_arr;
        }
+       
        return res_arr;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
@@ -635,18 +657,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDec
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
@@ -656,18 +680,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInv
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdownScript res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKInvalidShutdownScript err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
@@ -691,18 +717,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErr
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRouteHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
@@ -745,20 +773,71 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteParametersDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
+       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+       ret->datalen = *((uint32_t*)elems);
+       if (ret->datalen == 0) {
+               ret->data = NULL;
+       } else {
+               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ 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];
+                       LDKRouteHint arr_elem_conv;
+                       arr_elem_conv.inner = (void*)(arr_elem & (~1));
+                       arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       ret->data[i] = arr_elem_conv;
+               }
+       }
+       return (uint64_t)ret;
+}
+static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
+       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+       for (size_t i = 0; i < ret.datalen; i++) {
+               ret.data[i] = RouteHint_clone(&orig->data[i]);
+       }
+       return ret;
+}
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
        LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
        switch(obj->tag) {
@@ -771,55 +850,124 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(
                default: abort();
        }
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
-       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_PayeeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKPayee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintHopZ_new(uint32_tArray elems) {
+       LDKCVec_RouteHintHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHintHopZ), "LDKCVec_RouteHintHopZ");
        ret->datalen = *((uint32_t*)elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
+               ret->data = MALLOC(sizeof(LDKRouteHintHop) * ret->datalen, "LDKCVec_RouteHintHopZ 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];
-                       LDKChannelDetails arr_elem_conv;
+                       LDKRouteHintHop arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
+                       arr_elem_conv = RouteHintHop_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
-       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
+       LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
+               ret.data[i] = RouteHintHop_clone(&orig->data[i]);
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
-       LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteHintDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_RouteHintHopDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKRouteHintHop res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
+       LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
        ret->datalen = *((uint32_t*)elems);
        if (ret->datalen == 0) {
                ret->data = NULL;
        } else {
-               ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
+               ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ 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];
-                       LDKRouteHint arr_elem_conv;
+                       LDKChannelDetails arr_elem_conv;
                        arr_elem_conv.inner = (void*)(arr_elem & (~1));
                        arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
-                       arr_elem_conv = RouteHint_clone(&arr_elem_conv);
+                       arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
                        ret->data[i] = arr_elem_conv;
                }
        }
        return (uint64_t)ret;
 }
-static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
-       LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
+static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
+       LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
        for (size_t i = 0; i < ret.datalen; i++) {
-               ret.data[i] = RouteHint_clone(&orig->data[i]);
+               ret.data[i] = ChannelDetails_clone(&orig->data[i]);
        }
        return ret;
 }
@@ -830,18 +978,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErr
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
        LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
@@ -859,17 +1009,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ
        uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
        return err_conv;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
-       LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
-       ret->a = a;
-       LDKTransaction b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       b_ref.data_is_owned = false;
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -901,7 +1040,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransac
                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_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -941,18 +1082,36 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(
        switch(obj->tag) {
                case LDKMonitorEvent_HTLCEvent: {
                        LDKHTLCUpdate htlc_event_var = obj->htlc_event;
+                       uint64_t htlc_event_ref = 0;
                        CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
+                       htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
                        return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
                }
                case LDKMonitorEvent_CommitmentTxConfirmed: {
                        LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
+                       uint64_t commitment_tx_confirmed_ref = 0;
                        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;
+                       commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
                        return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
                }
+               case LDKMonitorEvent_UpdateCompleted: {
+                       LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
+                       uint64_t funding_txo_ref = 0;
+                       CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
+                       return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
+               }
+               case LDKMonitorEvent_UpdateFailed: {
+                       LDKOutPoint update_failed_var = obj->update_failed;
+                       uint64_t update_failed_ref = 0;
+                       CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
+                       return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
+               }
                default: abort();
        }
 }
@@ -966,7 +1125,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(ui
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(arr_elem_ptr);
                        arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1000,9 +1161,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr
        switch(obj->tag) {
                case LDKNetworkUpdate_ChannelUpdateMessage: {
                        LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
                }
                case LDKNetworkUpdate_ChannelClosed: {
@@ -1034,24 +1196,27 @@ uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_
        switch(obj->tag) {
                case LDKSpendableOutputDescriptor_StaticOutput: {
                        LDKOutPoint outpoint_var = obj->static_output.outpoint;
+                       uint64_t outpoint_ref = 0;
                        CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
+                       outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
                        uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
                        return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
                }
                case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
                        LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
+                       uint64_t delayed_payment_output_ref = 0;
                        CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
+                       delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
                        return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
                }
                case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
                        LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
+                       uint64_t static_payment_output_ref = 0;
                        CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
+                       static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
                        return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
                }
                default: abort();
@@ -1067,7 +1232,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescr
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
                        arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1086,9 +1253,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u
        switch(obj->tag) {
                case LDKErrorAction_DisconnectPeer: {
                        LDKErrorMessage msg_var = obj->disconnect_peer.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;
+                       uint64_t msg_ref = 0;
+                       if ((uint64_t)msg_var.inner > 4096) {
+                               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.
+                               msg_ref = (uint64_t)msg_var.inner & ~1;
+                       }
                        return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
                }
                case LDKErrorAction_IgnoreError: {
@@ -1100,9 +1270,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u
                }
                case LDKErrorAction_SendErrorMessage: {
                        LDKErrorMessage msg_var = obj->send_error_message.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
                }
                default: abort();
@@ -1115,133 +1286,149 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
                        LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendOpenChannel: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
                        LDKOpenChannel msg_var = obj->send_open_channel.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingCreated: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
                        LDKFundingCreated msg_var = obj->send_funding_created.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingSigned: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
                        LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendFundingLocked: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
                        LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendAnnouncementSignatures: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
                        LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_UpdateHTLCs: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
                        LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+                       uint64_t updates_ref = 0;
                        CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
+                       updates_ref = (uint64_t)updates_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
                }
                case LDKMessageSendEvent_SendRevokeAndACK: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
                        LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendClosingSigned: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
                        LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendShutdown: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
                        LDKShutdown msg_var = obj->send_shutdown.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendChannelReestablish: {
                        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_reestablish.node_id.compressed_form, 33);
                        LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
                        LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+                       uint64_t update_msg_ref = 0;
                        CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+                       update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
                }
                case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
                        LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
                }
                case LDKMessageSendEvent_BroadcastChannelUpdate: {
                        LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendChannelUpdate: {
                        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_update.node_id.compressed_form, 33);
                        LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_HandleError: {
@@ -1254,27 +1441,30 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_
                        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);
                        LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendShortIdsQuery: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
                        LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
                }
                case LDKMessageSendEvent_SendReplyChannelRange: {
                        int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
                        LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+                       uint64_t msg_ref = 0;
                        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;
+                       msg_ref = (uint64_t)msg_var.inner & ~1;
                        return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
                }
                default: abort();
@@ -1290,7 +1480,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_ne
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
                        arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -1311,18 +1503,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecod
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInitFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1332,18 +1526,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecod
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1353,18 +1549,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDe
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1374,18 +1572,66 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDe
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoiceFeatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScoringParameters res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
+       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.
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       LDKScorer res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
+       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.
+       res_ref = (uint64_t)res_var.inner & ~1;
+       return res_ref;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
+       LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1395,18 +1641,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOut
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1416,18 +1664,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutp
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
@@ -1443,9 +1693,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDe
        LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
@@ -1461,29 +1712,6 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uin
        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;
-       CHECK(*((uint32_t*)a) == 64);
-       memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
-       ret->a = a_ref;
-       LDKCVec_SignatureZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
-       else
-               b_constr.data = NULL;
-       int8_tArray* b_vals = (int8_tArray*)(b + 4);
-       for (size_t m = 0; m < b_constr.datalen; m++) {
-               int8_tArray b_conv_12 = b_vals[m];
-               LDKSignature b_conv_12_ref;
-               CHECK(*((uint32_t*)b_conv_12) == 64);
-               memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
-               b_constr.data[m] = b_conv_12_ref;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -1500,13 +1728,15 @@ static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(
 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
        LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -1596,15 +1826,18 @@ LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_a
 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;
+       uint64_t holder_tx_ref = 0;
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1619,15 +1852,18 @@ LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1636,22 +1872,27 @@ LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const vo
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
        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;
+       uint64_t commitment_tx_ref = 0;
        commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
        CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+       commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
        if (commitment_tx_var.is_owned) {
                commitment_tx_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
        ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1664,7 +1905,9 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const vo
        int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
        uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1677,15 +1920,18 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void
        int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
        uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -1698,55 +1944,65 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c
        int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
        LDKHTLCOutputInCommitment htlc_var = *htlc;
+       uint64_t htlc_ref = 0;
        htlc_var = HTLCOutputInCommitment_clone(htlc);
        CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t htlc_ref = (uint64_t)htlc_var.inner;
+       htlc_ref = (uint64_t)htlc_var.inner;
        if (htlc_var.is_owned) {
                htlc_ref |= 1;
        }
        uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        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, const LDKClosingTransaction * closing_tx) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKClosingTransaction closing_tx_var = *closing_tx;
-       // Warning: we may need a move here but no clone is available for LDKClosingTransaction
+       uint64_t closing_tx_ref = 0;
+       closing_tx_var = ClosingTransaction_clone(closing_tx);
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKUnsignedChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UnsignedChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
-       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
        LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
        LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+       uint64_t channel_parameters_ref = 0;
        channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
        CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+       channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
        if (channel_parameters_var.is_owned) {
                channel_parameters_ref |= 1;
        }
@@ -1793,21 +2049,27 @@ long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Objec
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
        return ret_arr;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction holder_tx_conv;
        holder_tx_conv.inner = (void*)(holder_tx & (~1));
        holder_tx_conv.is_owned = false;
@@ -1817,14 +2079,18 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_com
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
        return ret_arr;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -1834,7 +2100,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_c
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        unsigned char secret_arr[32];
        CHECK(*((uint32_t*)secret) == 32);
        memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
@@ -1845,7 +2113,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterpar
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKHolderCommitmentTransaction commitment_tx_conv;
        commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
        commitment_tx_conv.is_owned = false;
@@ -1855,7 +2125,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitm
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = *((uint32_t*)justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1871,7 +2143,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoke
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction justice_tx_ref;
        justice_tx_ref.datalen = *((uint32_t*)justice_tx);
        justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1890,7 +2164,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoke
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKTransaction htlc_tx_ref;
        htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
        htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
@@ -1908,7 +2184,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_h
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKClosingTransaction closing_tx_conv;
        closing_tx_conv.inner = (void*)(closing_tx & (~1));
        closing_tx_conv.is_owned = false;
@@ -1918,7 +2196,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transa
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -1928,7 +2208,9 @@ uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announ
 }
 
 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelTransactionParameters channel_parameters_conv;
        channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
        channel_parameters_conv.is_owned = false;
@@ -1941,11 +2223,14 @@ LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
        return this_arg->pubkeys;
 }
 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
-       LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
        LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2004,7 +2289,9 @@ long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Re
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
-       LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
        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);
@@ -2018,7 +2305,7 @@ 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* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *res_ret = Sign_clone(&(*val->contents.result));
        return (uint64_t)res_ret;
 }
@@ -2026,9 +2313,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_
        LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
@@ -2060,7 +2348,8 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNon
        LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
-       ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
        for (size_t m = 0; m < res_var.datalen; m++) {
                LDKCVec_u8Z res_conv_12_var = res_var.data[m];
@@ -2068,6 +2357,7 @@ ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNon
                memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
                res_arr_ptr[m] = res_conv_12_arr;
        }
+       
        return res_arr;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
@@ -2082,18 +2372,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDec
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInMemorySigner res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
@@ -2106,7 +2398,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tA
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
                        arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2136,19 +2430,6 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKChannelMonitor b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelMonitor_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2165,9 +2446,10 @@ static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LD
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
        LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
        LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2184,7 +2466,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashCha
                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_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2205,7 +2489,8 @@ uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
-       uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray res_arr = NULL;
+       res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
        uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
        for (size_t j = 0; j < res_var.datalen; j++) {
                LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
@@ -2213,6 +2498,7 @@ uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple
                *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
                res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
        }
+       
        return res_arr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
@@ -2221,27 +2507,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_Bloc
        uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
        return err_conv;
 }
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_result_ok(uint32_t arg) {
-       return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_get_ok(uint32_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKPaymentId 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_PaymentIdDecodeErrorZ_get_err(uint32_t arg) {
-       LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(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;
-}
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
        LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
        switch(obj->tag) {
@@ -2282,9 +2547,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint
                }
                case LDKAPIError_IncompatibleShutdownScript: {
                        LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+                       uint64_t script_ref = 0;
                        CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                        CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-                       uint64_t script_ref = (uint64_t)script_var.inner & ~1;
+                       script_ref = (uint64_t)script_var.inner & ~1;
                        return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
                }
                default: abort();
@@ -2314,7 +2580,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIError
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
                        arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2338,7 +2606,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
                        arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2377,7 +2647,8 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
                }
                case LDKPaymentSendFailure_PathParameterError: {
                        LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
-                       uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray path_parameter_error_arr = NULL;
+                       path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
                        for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
                                LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
@@ -2385,29 +2656,43 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
                                *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
                                path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
                        }
+                       
                        return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
                }
                case LDKPaymentSendFailure_AllFailedRetrySafe: {
                        LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
-                       uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray all_failed_retry_safe_arr = NULL;
+                       all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
                        for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
                                uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
                                all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
                        }
+                       
                        return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
                }
                case LDKPaymentSendFailure_PartialFailure: {
-                       LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
-                       uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
-                       uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
-                       for (size_t w = 0; w < partial_failure_var.datalen; w++) {
-                               LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
-                               *partial_failure_conv_22_conv = partial_failure_var.data[w];
-                               *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
-                               partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
+                       LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+                       uint32_tArray results_arr = NULL;
+                       results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
+                       for (size_t w = 0; w < results_var.datalen; w++) {
+                               LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+                               *results_conv_22_conv = results_var.data[w];
+                               *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+                               results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
+                       }
+                       
+                       LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+                       uint64_t failed_paths_retry_ref = 0;
+                       if ((uint64_t)failed_paths_retry_var.inner > 4096) {
+                               CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
                        }
-                       return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
+                       return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
                }
                default: abort();
        }
@@ -2415,14 +2700,12 @@ uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_fro
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(uint32_t arg) {
        return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
+int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKPaymentId 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;
+       int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+       return res_arr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
        LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
@@ -2444,19 +2727,6 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFa
        uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2467,19 +2737,14 @@ int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymen
        return ret_arr;
 }
 
-static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
-       return PaymentId_clone(&tuple->b);
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+       return ThirtyTwoBytes_clone(&tuple->b);
 }
-uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
+int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
        LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
-       LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_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;
+       int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
+       return ret_arr;
 }
 
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(uint32_t arg) {
@@ -2535,7 +2800,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
                        arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -2549,18 +2816,6 @@ static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddres
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
-       LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKThirtyTwoBytes b_ref;
-       CHECK(*((uint32_t*)b) == 32);
-       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -2641,42 +2896,50 @@ static void LDKWatch_JCalls_free(void* this_arg) {
 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
        LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitor monitor_var = monitor;
+       uint64_t monitor_ref = 0;
        CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t monitor_ref = (uint64_t)monitor_var.inner;
+       monitor_ref = (uint64_t)monitor_var.inner;
        if (monitor_var.is_owned) {
                monitor_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
        LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
        LDKOutPoint funding_txo_var = funding_txo;
+       uint64_t funding_txo_ref = 0;
        CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
+       funding_txo_ref = (uint64_t)funding_txo_var.inner;
        if (funding_txo_var.is_owned) {
                funding_txo_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = update;
+       uint64_t update_ref = 0;
        CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
+       update_ref = (uint64_t)update_var.inner;
        if (update_var.is_owned) {
                update_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2692,7 +2955,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void*
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t o = 0; o < ret_constr.datalen; o++) {
                uint32_t ret_conv_14 = ret_vals[o];
-               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
+               void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
+               CHECK_ACCESS(ret_conv_14_ptr);
+               LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
                ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
                ret_constr.data[o] = ret_conv_14_conv;
        }
@@ -2722,7 +2987,9 @@ long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object R
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -2737,7 +3004,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKOutPoint funding_txo_conv;
        funding_txo_conv.inner = (void*)(funding_txo & (~1));
        funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
@@ -2752,16 +3021,20 @@ uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_
 }
 
 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
-       LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
        LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -2807,7 +3080,9 @@ long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TO
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
-       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
        LDKTransaction tx_ref;
        tx_ref.datalen = *((uint32_t*)tx);
        tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
@@ -2868,7 +3143,9 @@ LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* t
 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
        LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
        uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
-       LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKSign ret_conv = *(LDKSign*)(ret_ptr);
        ret_conv = Sign_clone(&ret_conv);
        return ret_conv;
 }
@@ -2886,7 +3163,9 @@ LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void*
        int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
        uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
-       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2897,7 +3176,9 @@ LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const v
        memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
        CVec_u8Z_free(invoice_preimage_var);
        uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
-       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
        ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -2929,14 +3210,18 @@ long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS
        return (long)res_ptr;
 }
 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
        return ret_arr;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(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);
@@ -2945,11 +3230,14 @@ int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destina
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -2957,21 +3245,27 @@ 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_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+       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) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
        return ret_arr;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKu8slice reader_ref;
        reader_ref.datalen = *((uint32_t*)reader);
        reader_ref.data = (int8_t*)(reader + 4);
@@ -2981,7 +3275,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_sign
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
-       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
        LDKCVec_u8Z invoice_preimage_ref;
        invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
        invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
@@ -3029,7 +3325,9 @@ long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS O
        return (long)res_ptr;
 }
 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
-       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
        LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
        int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
        return ret_val;
@@ -3073,19 +3371,6 @@ long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object
        *res_ptr = LDKLogger_init(o);
        return (long)res_ptr;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
-       LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKChannelManager b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       // Warning: we need a move here but no clone is available for LDKChannelManager
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3102,9 +3387,10 @@ static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(L
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
        LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
        LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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 & ~1;
+       ret_ref = (uint64_t)ret_var.inner & ~1;
        return ret_ref;
 }
 
@@ -3114,8 +3400,7 @@ jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
-       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
-       *res_conv = (*val->contents.result);
+       LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
        // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
        return ((uint64_t)res_conv) | 1;
 }
@@ -3123,9 +3408,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
        LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3135,18 +3421,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDeco
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelConfig res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3156,18 +3444,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErr
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOutPoint res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKType_JCalls {
@@ -3229,13 +3519,17 @@ long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Re
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -3243,7 +3537,9 @@ jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
-       LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
        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);
@@ -3255,7 +3551,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr
        LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_TypeZ_Some: {
-                       LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
+                       LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
                        *some_ret = Type_clone(&obj->some);
                        return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
                }
@@ -3278,9 +3574,49 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDeco
        LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
+       return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
+       LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+       switch(obj->tag) {
+               case LDKPaymentError_Invoice: {
+                       LDKStr invoice_str = obj->invoice;
+                       jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
+                       return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
+               }
+               case LDKPaymentError_Routing: {
+                       LDKLightningError routing_var = obj->routing;
+                       uint64_t routing_ref = 0;
+                       CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       routing_ref = (uint64_t)routing_var.inner & ~1;
+                       return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
+               }
+               case LDKPaymentError_Sending: {
+                       uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
+                       return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
+               }
+               default: abort();
+       }
+}
+jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_result_ok(uint32_t arg) {
+       return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
+}
+int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(val->result_ok);
+       int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+       return res_arr;
+}
+uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
+       LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+       CHECK(!val->result_ok);
+       uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
@@ -3304,9 +3640,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_
        LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
@@ -3321,9 +3658,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceN
        LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKSignedRawInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
@@ -3331,33 +3669,16 @@ void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ
        CHECK(!val->result_ok);
        return *val->contents.err;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
-       LDKRawInvoice a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = RawInvoice_clone(&a_conv);
-       ret->a = a_conv;
-       LDKThirtyTwoBytes b_ref;
-       CHECK(*((uint32_t*)b) == 32);
-       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
-       ret->b = b_ref;
-       LDKInvoiceSignature c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = InvoiceSignature_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
        return RawInvoice_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3380,9 +3701,10 @@ static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignature
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
        LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
        LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3396,9 +3718,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ
        LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPayeePubKey res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
@@ -3440,9 +3763,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestamp
        LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPositiveTimestamp res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
@@ -3472,9 +3796,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticEr
        LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
@@ -3490,9 +3815,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreati
        LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDescription res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
@@ -3508,9 +3834,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreatio
        LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKExpiryTime res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
@@ -3526,9 +3853,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreat
        LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPrivateRoute res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
@@ -3560,18 +3888,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpd
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelMonitorUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -3581,18 +3911,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeE
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKHTLCUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
@@ -3607,34 +3939,22 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdate
        LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKMonitorUpdateError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
-       LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
-       LDKOutPoint a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = OutPoint_clone(&a_conv);
-       ret->a = a_conv;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
        return OutPoint_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
        LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
        LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -3653,16 +3973,6 @@ int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_g
        return ret_arr;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
-       LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
-       ret->a = a;
-       LDKCVec_u8Z b_ref;
-       b_ref.datalen = *((uint32_t*)b);
-       b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
-       memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
-       ret->b = b_ref;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -3694,7 +4004,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_
                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_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3708,28 +4020,6 @@ static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const L
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32ScriptZZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
-       else
-               b_constr.data = NULL;
-       uint32_t* b_vals = (uint32_t*)(b + 4);
-       for (size_t v = 0; v < b_constr.datalen; v++) {
-               uint32_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
-               b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
-               b_constr.data[v] = b_conv_21_conv;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -3746,13 +4036,15 @@ static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32Scr
 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 v = 0; v < ret_var.datalen; v++) {
                LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
                *ret_conv_21_conv = ret_var.data[v];
                ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -3767,7 +4059,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2T
                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_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3848,40 +4142,57 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_
                        return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
                }
                case LDKEvent_PaymentSent: {
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
                        int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
                        int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
-                       return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr; (void) payment_hash_arr;
+                       uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+                       return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
                }
                case LDKEvent_PaymentPathFailed: {
+                       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+                       memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
                        int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                        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_tArray path_arr = NULL;
+                       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];
+                               uint64_t path_conv_10_ref = 0;
                                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_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
                                path_arr_ptr[k] = path_conv_10_ref;
                        }
+                       
                        uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
-                       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; (void) short_channel_id_ref;
+                       LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+                       uint64_t retry_ref = 0;
+                       if ((uint64_t)retry_var.inner > 4096) {
+                               CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                               CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                               retry_ref = (uint64_t)retry_var.inner & ~1;
+                       }
+                       return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (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; (void) short_channel_id_ref; (void) retry_ref;
                }
                case LDKEvent_PendingHTLCsForwardable: {
                        return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
                }
                case LDKEvent_SpendableOutputs: {
                        LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
-                       uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray outputs_arr = NULL;
+                       outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
                        for (size_t b = 0; b < outputs_var.datalen; b++) {
                                uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
                                outputs_arr_ptr[b] = outputs_conv_27_ref;
                        }
+                       
                        return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
                }
                case LDKEvent_PaymentForwarded: {
@@ -3915,7 +4226,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tA
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
                        arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3929,14 +4242,6 @@ static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
-       LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
-       ret->a = a;
-       LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
-       b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
-       ret->b = b_conv;
-       return (uint64_t)ret;
-}
 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -3966,7 +4271,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_n
                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_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -3980,28 +4287,6 @@ static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDK
        }
        return ret;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
-       LDKThirtyTwoBytes a_ref;
-       CHECK(*((uint32_t*)a) == 32);
-       memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       ret->a = a_ref;
-       LDKCVec_C2Tuple_u32TxOutZZ b_constr;
-       b_constr.datalen = *((uint32_t*)b);
-       if (b_constr.datalen > 0)
-               b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
-       else
-               b_constr.data = NULL;
-       uint32_t* b_vals = (uint32_t*)(b + 4);
-       for (size_t u = 0; u < b_constr.datalen; u++) {
-               uint32_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
-               b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
-               b_constr.data[u] = b_conv_20_conv;
-       }
-       ret->b = b_constr;
-       return (uint64_t)ret;
-}
 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
        return ThirtyTwoBytes_clone(&tuple->a);
 }
@@ -4018,13 +4303,15 @@ static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOu
 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
        LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
        LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 u = 0; u < ret_var.datalen; u++) {
                LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
                *ret_conv_20_conv = ret_var.data[u];
                ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -4039,7 +4326,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2T
                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_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4081,7 +4370,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
                        arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4110,9 +4401,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHash
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
@@ -4127,22 +4419,12 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErro
        LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       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;
-}
 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
        return tuple->a;
 }
@@ -4158,7 +4440,7 @@ static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTy
 }
 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
        LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
-       LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
+       LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
        *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
        return (uint64_t)ret_ret;
 }
@@ -4173,7 +4455,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTyp
                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);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
                        arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4199,39 +4483,22 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErro
        LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKLightningError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
-uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
-       LDKChannelAnnouncement a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = (a & 1) || (a == 0);
-       a_conv = ChannelAnnouncement_clone(&a_conv);
-       ret->a = a_conv;
-       LDKChannelUpdate b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = ChannelUpdate_clone(&b_conv);
-       ret->b = b_conv;
-       LDKChannelUpdate c_conv;
-       c_conv.inner = (void*)(c & (~1));
-       c_conv.is_owned = (c & 1) || (c == 0);
-       c_conv = ChannelUpdate_clone(&c_conv);
-       ret->c = c_conv;
-       return (uint64_t)ret;
-}
 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
        return ChannelAnnouncement_clone(&tuple->a);
 }
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4244,9 +4511,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4259,9 +4527,10 @@ static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateCh
 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
        LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
        LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -4278,7 +4547,9 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnou
                uint32_t *java_elems = (uint32_t*)(elems + 4);
                for (size_t i = 0; i < ret->datalen; i++) {
                        uint32_t arr_elem = java_elems[i];
-                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
+                       void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+                       CHECK_ACCESS(arr_elem_ptr);
+                       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
                        arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
                        ret->data[i] = arr_elem_conv;
                }
@@ -4333,9 +4604,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandl
        LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
@@ -4350,9 +4622,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErr
        LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
@@ -4367,9 +4640,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErr
        LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKPeerHandleError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4379,18 +4653,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeError
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeId res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 typedef struct LDKAccess_JCalls {
@@ -4409,7 +4685,9 @@ LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, cons
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
        ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -4435,7 +4713,9 @@ long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
        unsigned char genesis_hash_arr[32];
        CHECK(*((uint32_t*)genesis_hash) == 32);
        memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
@@ -4449,7 +4729,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_p
        LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_AccessZ_Some: {
-                       LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
+                       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;
@@ -4467,18 +4747,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChanne
        LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKDirectionalChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       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);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4488,18 +4770,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecode
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4509,18 +4793,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecode
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRoutingFees res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4530,18 +4816,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementI
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncementInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
@@ -4570,18 +4858,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErr
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeInfo res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4591,18 +4881,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecod
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNetworkGraph res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
@@ -4610,12 +4902,14 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_
        switch(obj->tag) {
                case LDKCOption_CVec_NetAddressZZ_Some: {
                        LDKCVec_NetAddressZ some_var = obj->some;
-                       uint32_tArray some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+                       uint32_tArray some_arr = NULL;
+                       some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
                        uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
                        for (size_t m = 0; m < some_var.datalen; m++) {
                                uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
                                some_arr_ptr[m] = some_conv_12_ref;
                        }
+                       
                        return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
                }
                case LDKCOption_CVec_NetAddressZZ_None: {
@@ -4624,40 +4918,6 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_
                default: abort();
        }
 }
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
-       return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(val->result_ok);
-       uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
-       return res_ref;
-}
-int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
-       LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
-       CHECK(!val->result_ok);
-       return *val->contents.err;
-}
-jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
-       return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
-       CHECK(val->result_ok);
-       LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *res_conv = (*val->contents.result);
-       *res_conv = CResult_NetAddressu8Z_clone(res_conv);
-       return (uint64_t)res_conv;
-}
-uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(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_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
        return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
 }
@@ -4671,9 +4931,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeE
        LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
@@ -4787,18 +5048,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDeco
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAcceptChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4808,18 +5071,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSigna
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKAnnouncementSignatures res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4829,18 +5094,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablis
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelReestablish res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4850,18 +5117,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDeco
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4871,18 +5140,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeR
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKClosingSignedFeeRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4892,18 +5163,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedD
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKCommitmentSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4913,18 +5186,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDec
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingCreated res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4934,18 +5209,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDeco
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingSigned res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4955,18 +5232,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDeco
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKFundingLocked res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4976,18 +5255,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInit res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
@@ -4997,18 +5278,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecode
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKOpenChannel res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5018,18 +5301,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecod
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKRevokeAndACK res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5039,18 +5324,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErr
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKShutdown res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5060,18 +5347,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDec
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5081,18 +5370,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalform
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5102,18 +5393,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeEr
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFee res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5123,18 +5416,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLC
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateFulfillHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5144,18 +5439,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDeco
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUpdateAddHTLC res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5165,18 +5462,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPing res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5186,18 +5485,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKPong res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5207,18 +5508,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAn
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5228,18 +5531,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnounceme
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5249,18 +5554,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUp
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5270,18 +5577,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDeco
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKChannelUpdate res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5291,18 +5600,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecod
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKErrorMessage res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5312,18 +5623,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnou
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5333,18 +5646,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementD
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKNodeAnnouncement res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5354,18 +5669,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannel
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryShortChannelIds res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5375,18 +5692,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannel
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5396,18 +5715,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRange
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKQueryChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5417,18 +5738,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRange
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKReplyChannelRange res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
@@ -5438,18 +5761,20 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFi
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKGossipTimestampFilter res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
        LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
        CHECK(!val->result_ok);
        LDKDecodeError err_var = (*val->contents.err);
+       uint64_t err_ref = 0;
        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;
+       err_ref = (uint64_t)err_var.inner & ~1;
        return err_ref;
 }
 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
@@ -5472,9 +5797,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCrea
        LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKInvoice res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
@@ -5508,14 +5834,17 @@ void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32
 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;
+       uint64_t output_ref = 0;
        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;
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
        ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -5542,7 +5871,9 @@ long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
@@ -5554,7 +5885,9 @@ void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
        LDKWatchedOutput output_conv;
        output_conv.inner = (void*)(output & (~1));
        output_conv.is_owned = (output & 1) || (output == 0);
@@ -5569,7 +5902,7 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_p
        LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
        switch(obj->tag) {
                case LDKCOption_FilterZ_Some: {
-                       LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
+                       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;
@@ -5587,9 +5920,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMoni
        LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
        CHECK(val->result_ok);
        LDKLockedChannelMonitor res_var = (*val->contents.result);
+       uint64_t res_ref = 0;
        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;
+       res_ref = (uint64_t)res_var.inner & ~1;
        return res_ref;
 }
 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
@@ -5646,7 +5980,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t s = 0; s < ret_constr.datalen; s++) {
                uint32_t ret_conv_18 = ret_vals[s];
-               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
+               void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
+               CHECK_ACCESS(ret_conv_18_ptr);
+               LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
                ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
                ret_constr.data[s] = ret_conv_18_conv;
        }
@@ -5674,16 +6010,20 @@ long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new
        return (long)res_ptr;
 }
 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
-       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
        LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 s = 0; s < ret_var.datalen; s++) {
                LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
-               *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
+               *ret_conv_18_copy = ret_var.data[s];
                uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
                ret_arr_ptr[s] = ret_conv_18_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -5727,7 +6067,9 @@ long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS O
        return (long)res_ptr;
 }
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
        LDKEvent* event_conv = (LDKEvent*)event;
        (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
 }
@@ -5745,7 +6087,7 @@ 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* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
+       LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *handler_ret = handler;
        js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
 }
@@ -5771,8 +6113,12 @@ long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
-       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
-       LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
+       void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
+       CHECK_ACCESS(handler_ptr);
+       LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
        (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
 }
 
@@ -5825,7 +6171,9 @@ long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        LDKu8slice block_ref;
        block_ref.datalen = *((uint32_t*)block);
        block_ref.data = (int8_t*)(block + 4);
@@ -5833,7 +6181,9 @@ void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t
 }
 
 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
-       LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5863,13 +6213,15 @@ void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t
        int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(header_arr + 4), *header, 80);
        LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
-       uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray txdata_arr = NULL;
+       txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
        uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
        for (size_t c = 0; c < txdata_var.datalen; c++) {
                LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
                *txdata_conv_28_conv = txdata_var.data[c];
                txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
        }
+       
        FREE(txdata_var.data);
        js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
 }
@@ -5929,7 +6281,9 @@ long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5943,7 +6297,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(u
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
@@ -5951,7 +6307,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(u
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char txid_arr[32];
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
@@ -5960,7 +6318,9 @@ void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        unsigned char header_arr[80];
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
@@ -5969,15 +6329,19 @@ void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint3
 }
 
 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
-       LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
        LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -5995,55 +6359,82 @@ static void LDKPersist_JCalls_free(void* this_arg) {
                FREE(j_calls);
        }
 }
-LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       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);
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
+       uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        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) {
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
        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;
+       LDKOutPoint channel_id_var = channel_id;
+       uint64_t channel_id_ref = 0;
+       CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       channel_id_ref = (uint64_t)channel_id_var.inner;
+       if (channel_id_var.is_owned) {
+               channel_id_ref |= 1;
        }
        LDKChannelMonitorUpdate update_var = *update;
-       update_var = ChannelMonitorUpdate_clone(update);
-       CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
-       CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t update_ref = (uint64_t)update_var.inner;
-       if (update_var.is_owned) {
-               update_ref |= 1;
+       uint64_t update_ref = 0;
+       if ((uint64_t)update_var.inner > 4096) {
+               update_var = ChannelMonitorUpdate_clone(update);
+               CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               update_ref = (uint64_t)update_var.inner;
+               if (update_var.is_owned) {
+                       update_ref |= 1;
+               }
        }
        LDKChannelMonitor data_var = *data;
+       uint64_t data_ref = 0;
        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;
+       data_ref = (uint64_t)data_var.inner;
        if (data_var.is_owned) {
                data_ref |= 1;
        }
-       uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
-       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+       LDKMonitorUpdateId update_id_var = update_id;
+       uint64_t update_id_ref = 0;
+       CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       update_id_ref = (uint64_t)update_id_var.inner;
+       if (update_id_var.is_owned) {
+               update_id_ref |= 1;
+       }
+       uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
        ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6069,34 +6460,46 @@ long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object
        *res_ptr = LDKPersist_init(o);
        return (long)res_ptr;
 }
-uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+       *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
-       LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
-       LDKOutPoint id_conv;
-       id_conv.inner = (void*)(id & (~1));
-       id_conv.is_owned = (id & 1) || (id == 0);
-       id_conv = OutPoint_clone(&id_conv);
+uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
+       LDKOutPoint channel_id_conv;
+       channel_id_conv.inner = (void*)(channel_id & (~1));
+       channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
+       channel_id_conv = OutPoint_clone(&channel_id_conv);
        LDKChannelMonitorUpdate update_conv;
        update_conv.inner = (void*)(update & (~1));
        update_conv.is_owned = false;
        LDKChannelMonitor data_conv;
        data_conv.inner = (void*)(data & (~1));
        data_conv.is_owned = false;
+       LDKMonitorUpdateId update_id_conv;
+       update_id_conv.inner = (void*)(update_id & (~1));
+       update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
+       update_id_conv = MonitorUpdateId_clone(&update_id_conv);
        LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
-       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+       *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
        return (uint64_t)ret_conv;
 }
 
@@ -6155,17 +6558,19 @@ void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LD
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKOpenChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = OpenChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6176,17 +6581,19 @@ void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = their_features;
+       uint64_t their_features_ref = 0;
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKAcceptChannel msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AcceptChannel_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6197,10 +6604,11 @@ void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingCreated msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingCreated_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6211,10 +6619,11 @@ void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6225,10 +6634,11 @@ void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKFundingLocked msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = FundingLocked_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6239,18 +6649,20 @@ void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPub
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInitFeatures their_features_var = *their_features;
+       uint64_t their_features_ref = 0;
        their_features_var = InitFeatures_clone(their_features);
        CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+       their_features_ref = (uint64_t)their_features_var.inner;
        if (their_features_var.is_owned) {
                their_features_ref |= 1;
        }
        LDKShutdown msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Shutdown_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6261,10 +6673,11 @@ void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKClosingSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ClosingSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6275,10 +6688,11 @@ void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateAddHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateAddHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6289,10 +6703,11 @@ void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFulfillHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFulfillHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6303,10 +6718,11 @@ void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFailHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6317,10 +6733,11 @@ void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFailMalformedHTLC msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFailMalformedHTLC_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6331,10 +6748,11 @@ void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_ar
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKCommitmentSigned msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = CommitmentSigned_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6345,10 +6763,11 @@ void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKRevokeAndACK msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = RevokeAndACK_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6359,10 +6778,11 @@ void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKP
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKUpdateFee msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = UpdateFee_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6373,10 +6793,11 @@ void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* t
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKAnnouncementSignatures msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = AnnouncementSignatures_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6393,10 +6814,11 @@ void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPubl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInit msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = Init_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6407,10 +6829,11 @@ void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKChannelReestablish msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelReestablish_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6421,10 +6844,11 @@ void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg,
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6435,10 +6859,11 @@ void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublic
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKErrorMessage msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ErrorMessage_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
@@ -6488,7 +6913,9 @@ long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*T
        return (long)res_ptr;
 }
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6503,7 +6930,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_ope
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6518,7 +6947,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_acc
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6529,7 +6960,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6540,7 +6973,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6551,7 +6986,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_fun
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6565,7 +7002,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shu
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6576,7 +7015,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_clo
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6587,7 +7028,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6598,7 +7041,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6609,7 +7054,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6620,7 +7067,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6631,7 +7080,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_com
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6642,7 +7093,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_rev
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6653,7 +7106,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_upd
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6664,7 +7119,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_ann
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6672,7 +7129,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disco
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6683,7 +7142,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_conne
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6694,7 +7155,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_cha
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6705,7 +7168,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_cha
 }
 
 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -6748,45 +7213,54 @@ static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKNodeAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = NodeAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKChannelAnnouncement msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelAnnouncement_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
        LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
        LDKChannelUpdate msg_var = *msg;
+       uint64_t msg_ref = 0;
        msg_var = ChannelUpdate_clone(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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
-       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6802,7 +7276,9 @@ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t h = 0; h < ret_constr.datalen; h++) {
                uint32_t ret_conv_59 = ret_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
+               void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
+               CHECK_ACCESS(ret_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
                ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
                ret_constr.data[h] = ret_conv_59_conv;
        }
@@ -6835,10 +7311,11 @@ void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDK
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKInit init_var = *init;
+       uint64_t init_ref = 0;
        init_var = Init_clone(init);
        CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t init_ref = (uint64_t)init_var.inner;
+       init_ref = (uint64_t)init_var.inner;
        if (init_var.is_owned) {
                init_ref |= 1;
        }
@@ -6849,14 +7326,17 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKReplyChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6865,14 +7345,17 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKReplyShortChannelIdsEnd msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6881,14 +7364,17 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKQueryChannelRange msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6897,14 +7383,17 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH
        int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
        memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
        LDKQueryShortChannelIds msg_var = msg;
+       uint64_t msg_ref = 0;
        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;
+       msg_ref = (uint64_t)msg_var.inner;
        if (msg_var.is_owned) {
                msg_ref |= 1;
        }
        uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
-       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -6942,7 +7431,9 @@ long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*T
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKNodeAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6952,7 +7443,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6962,7 +7455,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKChannelUpdate msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
@@ -6972,43 +7467,54 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 h = 0; h < ret_var.datalen; h++) {
                LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
                *ret_conv_59_conv = ret_var.data[h];
                ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey starting_point_ref;
        CHECK(*((uint32_t*)starting_point) == 33);
        memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
        LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 s = 0; s < ret_var.datalen; s++) {
                LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
+               uint64_t ret_conv_18_ref = 0;
                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;
+               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;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7019,7 +7525,9 @@ void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routi
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7033,7 +7541,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7047,7 +7557,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7061,7 +7573,9 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
-       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
@@ -7091,7 +7605,9 @@ LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const voi
        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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
        ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7117,7 +7633,9 @@ long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TOD
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
        LDKu8slice buffer_ref;
        buffer_ref.datalen = *((uint32_t*)buffer);
        buffer_ref.data = (int8_t*)(buffer + 4);
@@ -7142,12 +7660,14 @@ static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
 }
 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");
+       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);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7163,7 +7683,9 @@ LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandle
        uint32_t* ret_vals = (uint32_t*)(ret + 4);
        for (size_t z = 0; z < ret_constr.datalen; z++) {
                uint32_t ret_conv_25 = ret_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
+               void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
+               CHECK_ACCESS(ret_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
                ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
                ret_constr.data[z] = ret_conv_25_conv;
        }
@@ -7195,8 +7717,12 @@ long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TO
        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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
+       void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
+       CHECK_ACCESS(msg_ptr);
+       LDKType msg_conv = *(LDKType*)(msg_ptr);
        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);
@@ -7206,15 +7732,19 @@ uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_
 }
 
 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);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
        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_tArray ret_arr = NULL;
+       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++) {
                LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
                *ret_conv_25_conv = ret_var.data[z];
                ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -7283,7 +7813,9 @@ long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO:
        return (long)res_ptr;
 }
 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = *((uint32_t*)data);
        data_ref.data = (int8_t*)(data + 4);
@@ -7292,12 +7824,16 @@ int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(ui
 }
 
 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
 }
 
 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
-       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
        int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
        return ret_val;
 }
@@ -7305,17 +7841,69 @@ int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_
 typedef struct LDKScore_JCalls {
        atomic_size_t refcnt;
        uint32_t channel_penalty_msat_meth;
+       uint32_t payment_path_failed_meth;
+       uint32_t write_meth;
 } LDKScore_JCalls;
 static void LDKScore_JCalls_free(void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
        if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
                js_free(j_calls->channel_penalty_msat_meth);
+               js_free(j_calls->payment_path_failed_meth);
+               js_free(j_calls->write_meth);
                FREE(j_calls);
        }
 }
-uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
+uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
+       LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+       LDKNodeId source_var = *source;
+       uint64_t source_ref = 0;
+       source_var = NodeId_clone(source);
+       CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       source_ref = (uint64_t)source_var.inner;
+       if (source_var.is_owned) {
+               source_ref |= 1;
+       }
+       LDKNodeId target_var = *target;
+       uint64_t target_ref = 0;
+       target_var = NodeId_clone(target);
+       CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       target_ref = (uint64_t)target_var.inner;
+       if (target_var.is_owned) {
+               target_ref |= 1;
+       }
+       return js_invoke_function_3(j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
+}
+void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+       LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
+       LDKCVec_RouteHopZ path_var = path;
+       uint32_tArray path_arr = NULL;
+       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];
+               uint64_t path_conv_10_ref = 0;
+               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.
+               path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
+               if (path_conv_10_var.is_owned) {
+                       path_conv_10_ref |= 1;
+               }
+               path_arr_ptr[k] = path_conv_10_ref;
+       }
+       
+       FREE(path_var.data);
+       js_invoke_function_2(j_calls->payment_path_failed_meth, path_arr, short_channel_id);
+}
+LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
-       return js_invoke_function_1(j_calls->channel_penalty_msat_meth, short_channel_id);
+       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 LDKScore_JCalls_cloned(LDKScore* new_obj) {
        LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
@@ -7329,6 +7917,8 @@ static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
        LDKScore ret = {
                .this_arg = (void*) calls,
                .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
+               .payment_path_failed = payment_path_failed_LDKScore_jcall,
+               .write = write_LDKScore_jcall,
                .free = LDKScore_JCalls_free,
        };
        return ret;
@@ -7338,12 +7928,53 @@ long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object R
        *res_ptr = LDKScore_init(o);
        return (long)res_ptr;
 }
-int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id) {
-       LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
-       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
+int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       LDKNodeId source_conv;
+       source_conv.inner = (void*)(source & (~1));
+       source_conv.is_owned = false;
+       LDKNodeId target_conv;
+       target_conv.inner = (void*)(target & (~1));
+       target_conv.is_owned = false;
+       int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
        return ret_val;
 }
 
+void  __attribute__((visibility("default"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+       }
+       (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Score_write(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
+       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;
+}
+
 typedef struct LDKChannelManagerPersister_JCalls {
        atomic_size_t refcnt;
        uint32_t persist_manager_meth;
@@ -7358,15 +7989,18 @@ static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
        LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
        LDKChannelManager channel_manager_var = *channel_manager;
+       uint64_t channel_manager_ref = 0;
        // Warning: we may need a move here but no clone is available for LDKChannelManager
        CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
        CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-       uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
+       channel_manager_ref = (uint64_t)channel_manager_var.inner;
        if (channel_manager_var.is_owned) {
                channel_manager_ref |= 1;
        }
        uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
-       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
        ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
        return ret_conv;
 }
@@ -7392,7 +8026,9 @@ long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/
        return (long)res_ptr;
 }
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
-       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
        LDKChannelManager channel_manager_conv;
        channel_manager_conv.inner = (void*)(channel_manager & (~1));
        channel_manager_conv.is_owned = false;
@@ -7424,6 +8060,293 @@ uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint
                default: abort();
        }
 }
+typedef struct LDKPayer_JCalls {
+       atomic_size_t refcnt;
+       uint32_t node_id_meth;
+       uint32_t first_hops_meth;
+       uint32_t send_payment_meth;
+       uint32_t retry_payment_meth;
+} LDKPayer_JCalls;
+static void LDKPayer_JCalls_free(void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+               js_free(j_calls->node_id_meth);
+               js_free(j_calls->first_hops_meth);
+               js_free(j_calls->send_payment_meth);
+               js_free(j_calls->retry_payment_meth);
+               FREE(j_calls);
+       }
+}
+LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       int8_tArray ret = js_invoke_function_0(j_calls->node_id_meth);
+       LDKPublicKey ret_ref;
+       CHECK(*((uint32_t*)ret) == 33);
+       memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
+       return ret_ref;
+}
+LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       uint32_tArray ret = js_invoke_function_0(j_calls->first_hops_meth);
+       LDKCVec_ChannelDetailsZ ret_constr;
+       ret_constr.datalen = *((uint32_t*)ret);
+       if (ret_constr.datalen > 0)
+               ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+       else
+               ret_constr.data = NULL;
+       uint32_t* ret_vals = (uint32_t*)(ret + 4);
+       for (size_t q = 0; q < ret_constr.datalen; q++) {
+               uint32_t ret_conv_16 = ret_vals[q];
+               LDKChannelDetails ret_conv_16_conv;
+               ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
+               ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
+               ret_conv_16_conv = ChannelDetails_clone(&ret_conv_16_conv);
+               ret_constr.data[q] = ret_conv_16_conv;
+       }
+       return ret_constr;
+}
+LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_hash_arr + 4), payment_hash.data, 32);
+       int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_secret_arr + 4), payment_secret.data, 32);
+       uint32_t ret = js_invoke_function_3(j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone((LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
+       LDKRoute route_var = *route;
+       uint64_t route_ref = 0;
+       route_var = Route_clone(route);
+       CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       route_ref = (uint64_t)route_var.inner;
+       if (route_var.is_owned) {
+               route_ref |= 1;
+       }
+       int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
+       uint32_t ret = js_invoke_function_2(j_calls->retry_payment_meth, route_ref, payment_id_arr);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
+       ret_conv = CResult_NonePaymentSendFailureZ_clone((LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
+       LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKPayer LDKPayer_init (/*TODO: JS Object Reference */void* o) {
+       LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       //TODO: Assign calls->o from o
+
+       LDKPayer ret = {
+               .this_arg = (void*) calls,
+               .node_id = node_id_LDKPayer_jcall,
+               .first_hops = first_hops_LDKPayer_jcall,
+               .send_payment = send_payment_LDKPayer_jcall,
+               .retry_payment = retry_payment_LDKPayer_jcall,
+               .free = LDKPayer_JCalls_free,
+       };
+       return ret;
+}
+long  __attribute__((visibility("default"))) TS_LDKPayer_new(/*TODO: JS Object Reference */void* o) {
+       LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *res_ptr = LDKPayer_init(o);
+       return (long)res_ptr;
+}
+int8_tArray  __attribute__((visibility("default"))) TS_Payer_node_id(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
+       return ret_arr;
+}
+
+uint32_tArray  __attribute__((visibility("default"))) TS_Payer_first_hops(uint32_t this_arg) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
+       uint32_tArray ret_arr = NULL;
+       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++) {
+               LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
+               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.
+               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;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_hash_ref;
+       CHECK(*((uint32_t*)payment_hash) == 32);
+       memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
+       LDKThirtyTwoBytes payment_secret_ref;
+       CHECK(*((uint32_t*)payment_secret) == 32);
+       memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
+       LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
+       LDKRoute route_conv;
+       route_conv.inner = (void*)(route & (~1));
+       route_conv.is_owned = false;
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
+       LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
+       *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
+       return (uint64_t)ret_conv;
+}
+
+typedef struct LDKRouter_JCalls {
+       atomic_size_t refcnt;
+       uint32_t find_route_meth;
+} LDKRouter_JCalls;
+static void LDKRouter_JCalls_free(void* this_arg) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+       if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+               js_free(j_calls->find_route_meth);
+               FREE(j_calls);
+       }
+}
+LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
+       int8_tArray payer_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(payer_arr + 4), payer.compressed_form, 33);
+       LDKRouteParameters params_var = *params;
+       uint64_t params_ref = 0;
+       params_var = RouteParameters_clone(params);
+       CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+       CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+       params_ref = (uint64_t)params_var.inner;
+       if (params_var.is_owned) {
+               params_ref |= 1;
+       }
+       LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
+       uint32_tArray first_hops_arr = NULL;
+       if (first_hops != NULL) {
+               LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
+               first_hops_arr = init_arr(first_hops_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+               uint32_t *first_hops_arr_ptr = (uint32_t*)(first_hops_arr + 4);
+               for (size_t q = 0; q < first_hops_var.datalen; q++) {
+                       LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
+                       uint64_t first_hops_conv_16_ref = 0;
+                       CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+                       CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+                       first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
+                       if (first_hops_conv_16_var.is_owned) {
+                               first_hops_conv_16_ref |= 1;
+                       }
+                       first_hops_arr_ptr[q] = first_hops_conv_16_ref;
+               }
+       
+       }
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_scorer = ((uint64_t)scorer) | 1;
+       uint32_t ret = js_invoke_function_4(j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
+       void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+       CHECK_ACCESS(ret_ptr);
+       LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
+       ret_conv = CResult_RouteLightningErrorZ_clone((LDKCResult_RouteLightningErrorZ*)(((uint64_t)ret) & ~1));
+       return ret_conv;
+}
+static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
+       LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
+       atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKRouter LDKRouter_init (/*TODO: JS Object Reference */void* o) {
+       LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
+       atomic_init(&calls->refcnt, 1);
+       //TODO: Assign calls->o from o
+
+       LDKRouter ret = {
+               .this_arg = (void*) calls,
+               .find_route = find_route_LDKRouter_jcall,
+               .free = LDKRouter_JCalls_free,
+       };
+       return ret;
+}
+long  __attribute__((visibility("default"))) TS_LDKRouter_new(/*TODO: JS Object Reference */void* o) {
+       LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *res_ptr = LDKRouter_init(o);
+       return (long)res_ptr;
+}
+uint32_t  __attribute__((visibility("default"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t params, uint32_tArray first_hops, uint32_t scorer) {
+       void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+       if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+       LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
+       LDKPublicKey payer_ref;
+       CHECK(*((uint32_t*)payer) == 33);
+       memcpy(payer_ref.compressed_form, (uint8_t*)(payer + 4), 33);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
+       LDKCVec_ChannelDetailsZ first_hops_constr;
+       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
+       if (first_hops != 0) {
+               first_hops_constr.datalen = *((uint32_t*)first_hops);
+               if (first_hops_constr.datalen > 0)
+                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
+               else
+                       first_hops_constr.data = NULL;
+               uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
+               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
+                       uint32_t first_hops_conv_16 = first_hops_vals[q];
+                       LDKChannelDetails first_hops_conv_16_conv;
+                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
+                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
+                       first_hops_constr.data[q] = first_hops_conv_16_conv;
+               }
+               first_hops_ptr = &first_hops_constr;
+       }
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
+       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
+       *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
+       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+       return (uint64_t)ret_conv;
+}
+
 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
        LDKStr ret_str = _ldk_get_compiled_version();
        jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
@@ -7459,7 +8382,9 @@ uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script
 
 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
        FREE((void*)_res);
        TxOut_free(_res_conv);
 }
@@ -7494,7 +8419,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(
 
 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SecretKeyErrorZ_free(_res_conv);
 }
@@ -7517,7 +8444,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(
 
 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PublicKeyErrorZ_free(_res_conv);
 }
@@ -7551,7 +8480,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
 }
@@ -7585,7 +8516,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDec
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
 }
@@ -7616,7 +8549,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxCreationKeysErrorZ_free(_res_conv);
 }
@@ -7644,7 +8579,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u32Z_free(_res_conv);
 }
@@ -7679,7 +8616,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitme
 
 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
 }
@@ -7713,7 +8652,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelT
 
 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -7747,7 +8688,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionPa
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
 }
@@ -7799,7 +8742,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTran
 
 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7833,7 +8778,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTrans
 
 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7863,7 +8810,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransa
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
 }
@@ -7890,7 +8839,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactio
 
 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
 }
@@ -7920,7 +8871,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTra
 
 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
 }
@@ -7953,7 +8906,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_SignatureZNoneZ_free(_res_conv);
 }
@@ -7987,7 +8942,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
 }
@@ -8013,7 +8970,7 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvali
        LDKInvalidShutdownScript e_conv;
        e_conv.inner = (void*)(e & (~1));
        e_conv.is_owned = (e & 1) || (e == 0);
-       // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
+       e_conv = InvalidShutdownScript_clone(&e_conv);
        LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
        *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
        return (uint64_t)ret_conv;
@@ -8021,14 +8978,23 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvali
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
-       LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
-       *ret_conv = CResult_NoneErrorZ_ok();
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
+       LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
+       *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
+       LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
+       *ret_conv = CResult_NoneErrorZ_ok();
        return (uint64_t)ret_conv;
 }
 
@@ -8041,7 +9007,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint3
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneErrorZ_free(_res_conv);
 }
@@ -8075,7 +9043,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteHopDecodeErrorZ_free(_res_conv);
 }
@@ -8156,7 +9126,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteDecodeErrorZ_free(_res_conv);
 }
@@ -8168,6 +9140,60 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_cl
        return (uint64_t)ret_conv;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteParameters o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteParameters_clone(&o_conv);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_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_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteParametersDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
+       LDKCVec_RouteHintZ _res_constr;
+       _res_constr.datalen = *((uint32_t*)_res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               _res_constr.data = NULL;
+       uint32_t* _res_vals = (uint32_t*)(_res + 4);
+       for (size_t l = 0; l < _res_constr.datalen; l++) {
+               uint32_t _res_conv_11 = _res_vals[l];
+               LDKRouteHint _res_conv_11_conv;
+               _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
+               _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
+               _res_constr.data[l] = _res_conv_11_conv;
+       }
+       CVec_RouteHintZ_free(_res_constr);
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
        *ret_copy = COption_u64Z_some(o);
@@ -8184,7 +9210,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u64Z_free(_res_conv);
 }
@@ -8197,6 +9225,132 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t
        return ret_ref;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = Payee_clone(&o_conv);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PayeeDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
+       LDKCVec_RouteHintHopZ _res_constr;
+       _res_constr.datalen = *((uint32_t*)_res);
+       if (_res_constr.datalen > 0)
+               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               _res_constr.data = NULL;
+       uint32_t* _res_vals = (uint32_t*)(_res + 4);
+       for (size_t o = 0; o < _res_constr.datalen; o++) {
+               uint32_t _res_conv_14 = _res_vals[o];
+               LDKRouteHintHop _res_conv_14_conv;
+               _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
+               _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
+               _res_constr.data[o] = _res_conv_14_conv;
+       }
+       CVec_RouteHintHopZ_free(_res_constr);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteHint o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHint_clone(&o_conv);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_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_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
+       LDKRouteHintHop o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = (o & 1) || (o == 0);
+       o_conv = RouteHintHop_clone(&o_conv);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_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_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
+       LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
+       return (uint64_t)ret_conv;
+}
+
 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
        LDKCVec_ChannelDetailsZ _res_constr;
        _res_constr.datalen = *((uint32_t*)_res);
@@ -8215,24 +9369,6 @@ void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32
        CVec_ChannelDetailsZ_free(_res_constr);
 }
 
-void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
-       LDKCVec_RouteHintZ _res_constr;
-       _res_constr.datalen = *((uint32_t*)_res);
-       if (_res_constr.datalen > 0)
-               _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               _res_constr.data = NULL;
-       uint32_t* _res_vals = (uint32_t*)(_res + 4);
-       for (size_t l = 0; l < _res_constr.datalen; l++) {
-               uint32_t _res_conv_11 = _res_vals[l];
-               LDKRouteHint _res_conv_11_conv;
-               _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
-               _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
-               _res_constr.data[l] = _res_conv_11_conv;
-       }
-       CVec_RouteHintZ_free(_res_constr);
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
        LDKRoute o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -8255,7 +9391,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RouteLightningErrorZ_free(_res_conv);
 }
@@ -8268,7 +9406,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
        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);
@@ -8284,7 +9424,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TxOutAccessErrorZ_free(_res_conv);
 }
@@ -8316,7 +9458,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_ne
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_usizeTransactionZ_free(_res_conv);
 }
@@ -8331,7 +9475,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_
        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_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
+               void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
+               CHECK_ACCESS(_res_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
                FREE((void*)_res_conv_28);
                _res_constr.data[c] = _res_conv_28_conv;
        }
@@ -8371,7 +9517,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUp
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
 }
@@ -8393,7 +9541,9 @@ void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_t
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                uint32_t _res_conv_14 = _res_vals[o];
-               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
+               void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
+               CHECK_ACCESS(_res_conv_14_ptr);
+               LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
                FREE((void*)_res_conv_14);
                _res_constr.data[o] = _res_conv_14_conv;
        }
@@ -8401,7 +9551,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
        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);
@@ -8418,7 +9570,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac
 
 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
 }
@@ -8432,7 +9586,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransac
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
-       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
        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);
@@ -8449,7 +9605,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none(
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        COption_NetworkUpdateZ_free(_res_conv);
 }
@@ -8472,7 +9630,9 @@ void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t b = 0; b < _res_constr.datalen; b++) {
                uint32_t _res_conv_27 = _res_vals[b];
-               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
+               void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
+               CHECK_ACCESS(_res_conv_27_ptr);
+               LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
                FREE((void*)_res_conv_27);
                _res_constr.data[b] = _res_conv_27_conv;
        }
@@ -8489,7 +9649,9 @@ void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t s = 0; s < _res_constr.datalen; s++) {
                uint32_t _res_conv_18 = _res_vals[s];
-               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
+               void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
+               CHECK_ACCESS(_res_conv_18_ptr);
+               LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
                FREE((void*)_res_conv_18);
                _res_constr.data[s] = _res_conv_18_conv;
        }
@@ -8518,7 +9680,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8545,7 +9709,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8572,7 +9738,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecod
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
 }
@@ -8599,11 +9767,71 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecod
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
+       LDKScoringParameters 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 LDKScoringParameters
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
+       LDKScorer 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 LDKScorer
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_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_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_ScorerDecodeErrorZ_free(_res_conv);
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
        LDKDelayedPaymentOutputDescriptor o_conv;
        o_conv.inner = (void*)(o & (~1));
@@ -8626,7 +9854,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutput
 
 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8660,7 +9890,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputD
 
 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8673,7 +9905,9 @@ 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
        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);
@@ -8692,7 +9926,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescr
 
 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
 }
@@ -8718,7 +9954,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneNoneZ_free(_res_conv);
 }
@@ -8762,13 +10000,17 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_Signat
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
 }
 
 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);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
        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);
@@ -8783,7 +10025,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVe
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
 }
@@ -8812,7 +10056,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err()
 
 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignatureNoneZ_free(_res_conv);
 }
@@ -8825,7 +10071,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
-       LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKSign o_conv = *(LDKSign*)(o_ptr);
        LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
        *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
        return (uint64_t)ret_conv;
@@ -8843,7 +10091,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignDecodeErrorZ_free(_res_conv);
 }
@@ -8880,7 +10130,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignature
 
 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RecoverableSignatureNoneZ_free(_res_conv);
 }
@@ -8940,7 +10192,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
 }
@@ -8974,7 +10228,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
 }
@@ -8996,7 +10252,9 @@ void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_7 = _res_vals[h];
-               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -9022,7 +10280,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_TransactionNoneZ_free(_res_conv);
 }
@@ -9056,7 +10316,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMoni
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
 }
@@ -9071,7 +10333,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMon
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t j = 0; j < _res_constr.datalen; j++) {
                uint32_t _res_conv_35 = _res_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
+               void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
+               CHECK_ACCESS(_res_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
                FREE((void*)_res_conv_35);
                _res_constr.data[j] = _res_conv_35_conv;
        }
@@ -9088,7 +10352,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
        uint32_t* o_vals = (uint32_t*)(o + 4);
        for (size_t j = 0; j < o_constr.datalen; j++) {
                uint32_t o_conv_35 = o_vals[j];
-               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
+               void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
+               CHECK_ACCESS(o_conv_35_ptr);
+               LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
                o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
                o_constr.data[j] = o_conv_35_conv;
        }
@@ -9106,7 +10372,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
 }
@@ -9118,40 +10386,6 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHa
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_ok(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
-       return (uint64_t)ret_conv;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_PaymentIdDecodeErrorZ_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_clone(uint32_t orig) {
-       LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
        LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
        *ret_copy = COption_u16Z_some(o);
@@ -9168,7 +10402,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
 
 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
        FREE((void*)_res);
        COption_u16Z_free(_res_conv);
 }
@@ -9188,7 +10424,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -9197,7 +10435,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(ui
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneAPIErrorZ_free(_res_conv);
 }
@@ -9219,7 +10459,9 @@ void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t w = 0; w < _res_constr.datalen; w++) {
                uint32_t _res_conv_22 = _res_vals[w];
-               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
+               void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
+               CHECK_ACCESS(_res_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
                FREE((void*)_res_conv_22);
                _res_constr.data[w] = _res_conv_22_conv;
        }
@@ -9236,7 +10478,9 @@ void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArra
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t k = 0; k < _res_constr.datalen; k++) {
                uint32_t _res_conv_10 = _res_vals[k];
-               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
+               void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
+               CHECK_ACCESS(_res_conv_10_ptr);
+               LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
                FREE((void*)_res_conv_10);
                _res_constr.data[k] = _res_conv_10_conv;
        }
@@ -9253,7 +10497,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(in
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
-       LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
        LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
        *ret_conv = CResult__u832APIErrorZ_err(e_conv);
@@ -9262,7 +10508,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(u
 
 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult__u832APIErrorZ_free(_res_conv);
 }
@@ -9274,18 +10522,19 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = (o & 1) || (o == 0);
-       o_conv = PaymentId_clone(&o_conv);
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK(*((uint32_t*)o) == 32);
+       memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
-       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
+       *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
        return (uint64_t)ret_conv;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
        *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
@@ -9294,7 +10543,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSend
 
 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
 }
@@ -9313,7 +10564,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        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);
@@ -9322,7 +10575,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailu
 
 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePaymentSendFailureZ_free(_res_conv);
 }
@@ -9341,28 +10596,31 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentId
        return ((uint64_t)ret_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
+uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
        LDKThirtyTwoBytes a_ref;
        CHECK(*((uint32_t*)a) == 32);
        memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = (b & 1) || (b == 0);
-       b_conv = PaymentId_clone(&b_conv);
+       LDKThirtyTwoBytes b_ref;
+       CHECK(*((uint32_t*)b) == 32);
+       memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
        LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
-       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
+       *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
        return ((uint64_t)ret_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
-       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
        o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
@@ -9370,7 +10628,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashP
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
-       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
        e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
        LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
        *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
@@ -9379,7 +10639,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashP
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
 }
@@ -9401,7 +10663,9 @@ void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tAr
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t m = 0; m < _res_constr.datalen; m++) {
                uint32_t _res_conv_12 = _res_vals[m];
-               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
+               void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
+               CHECK_ACCESS(_res_conv_12_ptr);
+               LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
                FREE((void*)_res_conv_12);
                _res_constr.data[m] = _res_conv_12_conv;
        }
@@ -9429,7 +10693,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSe
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
 }
@@ -9444,7 +10710,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
        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);
@@ -9453,7 +10721,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErro
 
 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PaymentSecretAPIErrorZ_free(_res_conv);
 }
@@ -9498,13 +10768,17 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMana
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
-       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
        // 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);
@@ -9523,7 +10797,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashCha
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
 }
@@ -9550,7 +10826,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
 }
@@ -9584,7 +10862,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OutPointDecodeErrorZ_free(_res_conv);
 }
@@ -9597,7 +10877,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
-       LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKType o_conv = *(LDKType*)(o_ptr);
        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;
@@ -9613,7 +10895,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
        FREE((void*)_res);
        COption_TypeZ_free(_res_conv);
 }
@@ -9627,7 +10911,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
-       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
        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);
@@ -9646,7 +10932,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeE
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
 }
@@ -9658,6 +10946,41 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeE
        return (uint64_t)ret_conv;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
+       LDKThirtyTwoBytes o_ref;
+       CHECK(*((uint32_t*)o) == 32);
+       memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
+       e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
+       if ((_res & 1) != 0) return;
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
+       FREE((void*)_res);
+       CResult_PaymentIdPaymentErrorZ_free(_res_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
+       LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = CResult_PaymentIdPaymentErrorZ_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");
@@ -9673,7 +10996,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err()
 
 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SiPrefixNoneZ_free(_res_conv);
 }
@@ -9703,7 +11028,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceNoneZ_free(_res_conv);
 }
@@ -9733,7 +11060,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNone
 
 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_SignedRawInvoiceNoneZ_free(_res_conv);
 }
@@ -9771,7 +11100,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832Invoi
 
 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
 }
@@ -9795,7 +11126,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_er
 
 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PayeePubKeyErrorZ_free(_res_conv);
 }
@@ -9844,7 +11177,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCre
 
 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
 }
@@ -9871,7 +11206,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_e
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneSemanticErrorZ_free(_res_conv);
 }
@@ -9902,7 +11239,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticError
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSemanticErrorZ_free(_res_conv);
 }
@@ -9933,7 +11272,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationE
 
 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DescriptionCreationErrorZ_free(_res_conv);
 }
@@ -9964,7 +11305,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationEr
 
 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
 }
@@ -9995,7 +11338,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreation
 
 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PrivateRouteCreationErrorZ_free(_res_conv);
 }
@@ -10023,7 +11368,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uin
 
 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_StringErrorZ_free(_res_conv);
 }
@@ -10050,7 +11397,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdate
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -10084,7 +11433,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErro
 
 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -10114,7 +11465,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErr
 
 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
 }
@@ -10149,7 +11502,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_OutPointScriptZ_free(_res_conv);
 }
@@ -10173,7 +11528,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32ScriptZ_free(_res_conv);
 }
@@ -10188,7 +11545,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(ui
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t v = 0; v < _res_constr.datalen; v++) {
                uint32_t _res_conv_21 = _res_vals[v];
-               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
+               void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
+               CHECK_ACCESS(_res_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
                FREE((void*)_res_conv_21);
                _res_constr.data[v] = _res_conv_21_conv;
        }
@@ -10215,7 +11574,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
        uint32_t* b_vals = (uint32_t*)(b + 4);
        for (size_t v = 0; v < b_constr.datalen; v++) {
                uint32_t b_conv_21 = b_vals[v];
-               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
+               void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
+               CHECK_ACCESS(b_conv_21_ptr);
+               LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
                b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
                b_constr.data[v] = b_conv_21_conv;
        }
@@ -10226,7 +11587,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
 }
@@ -10241,7 +11604,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t o = 0; o < _res_constr.datalen; o++) {
                uint32_t _res_conv_40 = _res_vals[o];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
+               void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
+               CHECK_ACCESS(_res_conv_40_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
                FREE((void*)_res_conv_40);
                _res_constr.data[o] = _res_conv_40_conv;
        }
@@ -10258,7 +11623,9 @@ void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_7 = _res_vals[h];
-               LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
+               void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
+               CHECK_ACCESS(_res_conv_7_ptr);
+               LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
                FREE((void*)_res_conv_7);
                _res_constr.data[h] = _res_conv_7_conv;
        }
@@ -10293,7 +11660,9 @@ 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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
        b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
        LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
        *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
@@ -10302,7 +11671,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_u32TxOutZ_free(_res_conv);
 }
@@ -10317,7 +11688,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uin
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t u = 0; u < _res_constr.datalen; u++) {
                uint32_t _res_conv_20 = _res_vals[u];
-               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
+               void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
+               CHECK_ACCESS(_res_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
                FREE((void*)_res_conv_20);
                _res_constr.data[u] = _res_conv_20_conv;
        }
@@ -10344,7 +11717,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
        uint32_t* b_vals = (uint32_t*)(b + 4);
        for (size_t u = 0; u < b_constr.datalen; u++) {
                uint32_t b_conv_20 = b_vals[u];
-               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
+               void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
+               CHECK_ACCESS(b_conv_20_ptr);
+               LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
                b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
                b_constr.data[u] = b_conv_20_conv;
        }
@@ -10355,7 +11730,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32
 
 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
 }
@@ -10370,7 +11747,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u3
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t n = 0; n < _res_constr.datalen; n++) {
                uint32_t _res_conv_39 = _res_vals[n];
-               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
+               void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
+               CHECK_ACCESS(_res_conv_39_ptr);
+               LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
                FREE((void*)_res_conv_39);
                _res_constr.data[n] = _res_conv_39_conv;
        }
@@ -10387,7 +11766,9 @@ void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray
        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);
+               void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
+               CHECK_ACCESS(_res_conv_9_ptr);
+               LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
                FREE((void*)_res_conv_9);
                _res_constr.data[j] = _res_conv_9_conv;
        }
@@ -10395,7 +11776,9 @@ void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
-       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
        o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
@@ -10414,7 +11797,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashCha
 
 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
 }
@@ -10444,7 +11829,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NoneLightningErrorZ_free(_res_conv);
 }
@@ -10467,7 +11854,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(i
        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);
+       void* b_ptr = (void*)(((uint64_t)b) & ~1);
+       CHECK_ACCESS(b_ptr);
+       LDKType b_conv = *(LDKType*)(b_ptr);
        LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
        *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
        return ((uint64_t)ret_conv);
@@ -10475,7 +11864,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(i
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
        FREE((void*)_res);
        C2Tuple_PublicKeyTypeZ_free(_res_conv);
 }
@@ -10490,7 +11881,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_fre
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t z = 0; z < _res_constr.datalen; z++) {
                uint32_t _res_conv_25 = _res_vals[z];
-               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
+               void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
+               CHECK_ACCESS(_res_conv_25_ptr);
+               LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
                FREE((void*)_res_conv_25);
                _res_constr.data[z] = _res_conv_25_conv;
        }
@@ -10515,7 +11908,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolLightningErrorZ_free(_res_conv);
 }
@@ -10554,7 +11949,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementC
 
 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
        FREE((void*)_res);
        C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
 }
@@ -10569,7 +11966,9 @@ void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncement
        uint32_t* _res_vals = (uint32_t*)(_res + 4);
        for (size_t h = 0; h < _res_constr.datalen; h++) {
                uint32_t _res_conv_59 = _res_vals[h];
-               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
+               void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
+               CHECK_ACCESS(_res_conv_59_ptr);
+               LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
                FREE((void*)_res_conv_59);
                _res_constr.data[h] = _res_conv_59_conv;
        }
@@ -10634,7 +12033,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleEr
 
 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
 }
@@ -10664,7 +12065,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NonePeerHandleErrorZ_free(_res_conv);
 }
@@ -10694,7 +12097,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_boolPeerHandleErrorZ_free(_res_conv);
 }
@@ -10728,7 +12133,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_e
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeIdDecodeErrorZ_free(_res_conv);
 }
@@ -10741,7 +12148,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_c
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
-       LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKAccess o_conv = *(LDKAccess*)(o_ptr);
        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;
@@ -10757,7 +12166,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
        FREE((void*)_res);
        COption_AccessZ_free(_res_conv);
 }
@@ -10784,7 +12195,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelIn
 
 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10818,7 +12231,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10852,7 +12267,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
 }
@@ -10886,7 +12303,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfo
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10935,7 +12354,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeInfoDecodeErrorZ_free(_res_conv);
 }
@@ -10969,7 +12390,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
 }
@@ -10991,7 +12414,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_so
        uint32_t* o_vals = (uint32_t*)(o + 4);
        for (size_t m = 0; m < o_constr.datalen; m++) {
                uint32_t o_conv_12 = o_vals[m];
-               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
+               void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
+               CHECK_ACCESS(o_conv_12_ptr);
+               LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
                o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
                o_constr.data[m] = o_conv_12_conv;
        }
@@ -11010,7 +12435,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_no
 
 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
        FREE((void*)_res);
        COption_CVec_NetAddressZZ_free(_res_conv);
 }
@@ -11023,68 +12450,10 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_cl
        return ret_ref;
 }
 
-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;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_err(e);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_NetAddressu8Z_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
-       LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
-       LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
-       *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
-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;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
-       return (uint64_t)ret_conv;
-}
-
-void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
-       if ((_res & 1) != 0) return;
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
-       FREE((void*)_res);
-       CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
-       LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
        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);
@@ -11103,7 +12472,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErro
 
 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NetAddressDecodeErrorZ_free(_res_conv);
 }
@@ -11209,7 +12580,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
 }
@@ -11243,7 +12616,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignatur
 
 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
 }
@@ -11277,7 +12652,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDe
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
 }
@@ -11311,7 +12688,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11345,7 +12724,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRang
 
 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
 }
@@ -11379,7 +12760,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDeco
 
 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11413,7 +12796,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
 }
@@ -11447,7 +12832,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingSignedDecodeErrorZ_free(_res_conv);
 }
@@ -11481,7 +12868,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_FundingLockedDecodeErrorZ_free(_res_conv);
 }
@@ -11515,7 +12904,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InitDecodeErrorZ_free(_res_conv);
 }
@@ -11549,7 +12940,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErr
 
 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_OpenChannelDecodeErrorZ_free(_res_conv);
 }
@@ -11583,7 +12976,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
 }
@@ -11617,7 +13012,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ
 
 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ShutdownDecodeErrorZ_free(_res_conv);
 }
@@ -11651,7 +13048,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecode
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11685,7 +13084,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedH
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11719,7 +13120,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeError
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
 }
@@ -11753,7 +13156,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDec
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11787,7 +13192,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
 }
@@ -11821,7 +13228,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PingDecodeErrorZ_free(_res_conv);
 }
@@ -11855,7 +13264,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err
 
 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_PongDecodeErrorZ_free(_res_conv);
 }
@@ -11889,7 +13300,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnou
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -11923,7 +13336,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementD
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -11957,7 +13372,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdat
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -11991,7 +13408,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeE
 
 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
 }
@@ -12025,7 +13444,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeEr
 
 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
 }
@@ -12059,7 +13480,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnounce
 
 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -12093,7 +13516,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDeco
 
 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
 }
@@ -12127,7 +13552,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIds
 
 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
 }
@@ -12161,7 +13588,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIds
 
 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
 }
@@ -12195,7 +13624,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDec
 
 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -12229,7 +13660,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDec
 
 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
 }
@@ -12263,7 +13696,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilte
 
 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
 }
@@ -12286,7 +13721,9 @@ 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);
+       void* e_ptr = (void*)(((uint64_t)e) & ~1);
+       CHECK_ACCESS(e_ptr);
+       LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
        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);
@@ -12295,7 +13732,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio
 
 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
 }
@@ -12308,7 +13747,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
-       LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
+       void* o_ptr = (void*)(((uint64_t)o) & ~1);
+       CHECK_ACCESS(o_ptr);
+       LDKFilter o_conv = *(LDKFilter*)(o_ptr);
        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;
@@ -12324,7 +13765,9 @@ uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
 
 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);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
        FREE((void*)_res);
        COption_FilterZ_free(_res_conv);
 }
@@ -12347,7 +13790,9 @@ uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitor
 
 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
        if ((_res & 1) != 0) return;
-       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
+       void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
+       CHECK_ACCESS(_res_ptr);
+       LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
        FREE((void*)_res);
        CResult_LockedChannelMonitorNoneZ_free(_res_conv);
 }
@@ -12372,7 +13817,9 @@ void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArra
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentPurpose_free(this_ptr_conv);
 }
@@ -12410,7 +13857,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_p
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ClosureReason_free(this_ptr_conv);
 }
@@ -12485,7 +13934,9 @@ int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint3
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Event_free(this_ptr_conv);
 }
@@ -12516,7 +13967,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
+       CHECK_ACCESS(purpose_ptr);
+       LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
        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);
@@ -12524,24 +13977,36 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage, int8_tArray payment_hash) {
+uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKThirtyTwoBytes payment_preimage_ref;
        CHECK(*((uint32_t*)payment_preimage) == 32);
        memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
        LDKThirtyTwoBytes payment_hash_ref;
        CHECK(*((uint32_t*)payment_hash) == 32);
        memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
+       void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
+       CHECK_ACCESS(fee_paid_msat_ptr);
+       LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
+       fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
+       *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-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, uint32_t short_channel_id) {
+uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path, uint32_t short_channel_id, uint32_t retry) {
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        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);
+       void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
+       CHECK_ACCESS(network_update_ptr);
+       LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
        network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
        LDKCVec_RouteHopZ path_constr;
        path_constr.datalen = *((uint32_t*)path);
@@ -12558,10 +14023,16 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(in
                path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
                path_constr.data[k] = path_conv_10_conv;
        }
-       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
+       void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
+       CHECK_ACCESS(short_channel_id_ptr);
+       LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
        short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
+       LDKRouteParameters retry_conv;
+       retry_conv.inner = (void*)(retry & (~1));
+       retry_conv.is_owned = (retry & 1) || (retry == 0);
+       retry_conv = RouteParameters_clone(&retry_conv);
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-       *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
+       *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -12583,7 +14054,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint
        uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
        for (size_t b = 0; b < outputs_constr.datalen; b++) {
                uint32_t outputs_conv_27 = outputs_vals[b];
-               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
+               void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
+               CHECK_ACCESS(outputs_conv_27_ptr);
+               LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
                outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
                outputs_constr.data[b] = outputs_conv_27_conv;
        }
@@ -12594,7 +14067,9 @@ 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);
+       void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
+       CHECK_ACCESS(fee_earned_msat_ptr);
+       LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
        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);
@@ -12606,7 +14081,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tA
        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);
+       void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
+       CHECK_ACCESS(reason_ptr);
+       LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
        reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
        LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
        *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
@@ -12640,7 +14117,9 @@ int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj)
 
 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEvent_free(this_ptr_conv);
 }
@@ -12862,7 +14341,9 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_erro
        LDKPublicKey node_id_ref;
        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);
+       void* action_ptr = (void*)(((uint64_t)action) & ~1);
+       CHECK_ACCESS(action_ptr);
+       LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
        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);
@@ -12914,28 +14395,36 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_
 
 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MessageSendEventsProvider_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventsProvider_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        EventHandler_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        APIError_free(this_ptr_conv);
 }
@@ -13084,7 +14573,9 @@ uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
 
 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Logger_free(this_ptr_conv);
 }
@@ -13143,9 +14634,10 @@ void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_h
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13157,9 +14649,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13168,9 +14661,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
        LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13306,9 +14800,10 @@ void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13320,9 +14815,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13331,9 +14827,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
        LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13454,9 +14951,10 @@ void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_av
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
        LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13468,9 +14966,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13479,9 +14978,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
        LDKChannelConfig ret_var = ChannelConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13520,9 +15020,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_c
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13545,9 +15046,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13570,9 +15072,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_optio
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13619,9 +15122,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_
        channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
        channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
        LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13633,9 +15137,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13644,9 +15149,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t or
 
 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
        LDKUserConfig ret_var = UserConfig_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13665,9 +15171,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t ori
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13677,9 +15184,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t ori
 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
        LDKNetwork network_conv = LDKNetwork_from_js(network);
        LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13691,9 +15199,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray bl
        CHECK(*((uint32_t*)block_hash) == 32);
        memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
        LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13735,21 +15244,27 @@ uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
 
 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Access_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Listen_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Confirm_free(this_ptr_conv);
 }
@@ -13772,14 +15287,18 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_perm
 
 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Watch_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Filter_free(this_ptr_conv);
 }
@@ -13815,9 +15334,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13869,9 +15389,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArra
        script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
        LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13883,9 +15404,10 @@ uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -13902,7 +15424,9 @@ int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o
 
 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BroadcasterInterface_free(this_ptr_conv);
 }
@@ -13937,46 +15461,102 @@ jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32
 
 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        FeeEstimator_free(this_ptr_conv);
 }
 
-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);
-       FREE((void*)this_ptr);
-       Persist_free(this_ptr_conv);
-}
-
-void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
-       LDKLockedChannelMonitor this_obj_conv;
+void  __attribute__((visibility("default"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
+       LDKMonitorUpdateId this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       LockedChannelMonitor_free(this_obj_conv);
+       MonitorUpdateId_free(this_obj_conv);
 }
 
-void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
-       LDKChainMonitor this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       ChainMonitor_free(this_obj_conv);
+uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone(uint32_t orig) {
+       LDKMonitorUpdateId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_hash(uint32_t o) {
+       LDKMonitorUpdateId o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = MonitorUpdateId_hash(&o_conv);
+       return ret_val;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
+       LDKMonitorUpdateId a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKMonitorUpdateId b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Persist_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
+       LDKLockedChannelMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       LockedChannelMonitor_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
+       LDKChainMonitor this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ChainMonitor_free(this_obj_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
-       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
+       void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
+       CHECK_ACCESS(chain_source_ptr);
+       LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
        // 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);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
+       CHECK_ACCESS(feeest_ptr);
+       LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
        LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14003,14 +15583,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claima
                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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = 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;
 }
@@ -14033,27 +15615,47 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monit
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 k = 0; k < ret_var.datalen; k++) {
                LDKOutPoint ret_conv_10_var = ret_var.data[k];
+               uint64_t ret_conv_10_ref = 0;
                CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
+               ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
                if (ret_conv_10_var.is_owned) {
                        ret_conv_10_ref |= 1;
                }
                ret_arr_ptr[k] = ret_conv_10_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
+       LDKChainMonitor this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorUpdateId completed_update_id_conv;
+       completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
+       completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
+       completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
+       LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+       *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
+       return (uint64_t)ret_conv;
+}
+
 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_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14062,7 +15664,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14071,7 +15673,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
+       LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
        *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14080,7 +15682,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvid
        LDKChainMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -14112,9 +15714,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14148,14 +15751,46 @@ void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t
        MonitorUpdateError_free(this_obj_conv);
 }
 
+jstring  __attribute__((visibility("default"))) TS_MonitorUpdateError_get_a(uint32_t this_ptr) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
+       jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+       Str_free(ret_str);
+       return ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_MonitorUpdateError_set_a(uint32_t this_ptr, jstring val) {
+       LDKMonitorUpdateError this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKStr val_conv = str_ref_to_owned_c(val);
+       MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_new(jstring a_arg) {
+       LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
+       LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
        LDKMonitorUpdateError orig_conv;
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14164,7 +15799,9 @@ uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uin
 
 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        MonitorEvent_free(this_ptr_conv);
 }
@@ -14199,6 +15836,37 @@ uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_c
        return ret_ref;
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
+       LDKOutPoint funding_txo_conv;
+       funding_txo_conv.inner = (void*)(funding_txo & (~1));
+       funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+       funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+       LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+       *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_failed(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_update_failed(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_MonitorEvent_write(uint32_t obj) {
+       LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
+       LDKCVec_u8Z ret_var = MonitorEvent_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_HTLCUpdate_free(uint32_t this_obj) {
        LDKHTLCUpdate this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -14211,9 +15879,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14242,7 +15911,9 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Balance_free(this_ptr_conv);
 }
@@ -14302,9 +15973,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14329,9 +16001,15 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_update_monito
        LDKChannelMonitorUpdate updates_conv;
        updates_conv.inner = (void*)(updates & (~1));
        updates_conv.is_owned = false;
-       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
+       LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
+       LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
        *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
        return (uint64_t)ret_conv;
@@ -14359,13 +16037,15 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outp
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
                *ret_conv_40_conv = ret_var.data[o];
                ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14374,7 +16054,9 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_w
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
+       void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
+       if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
+       LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
        ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
 }
 
@@ -14383,14 +16065,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
-               *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
+               *ret_conv_14_copy = ret_var.data[o];
                uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14400,14 +16084,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 h = 0; h < ret_var.datalen; h++) {
                LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
-               *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
+               *ret_conv_7_copy = ret_var.data[h];
                uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
                ret_arr_ptr[h] = ret_conv_7_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14416,9 +16102,12 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_ho
        LDKChannelMonitor this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
+       LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
        LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                LDKTransaction ret_conv_12_var = ret_var.data[m];
@@ -14427,6 +16116,7 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_ho
                Transaction_free(ret_conv_12_var);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14448,21 +16138,31 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_block_co
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14475,9 +16175,15 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnecte
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
 }
 
@@ -14498,21 +16204,31 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_transact
        uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
        for (size_t c = 0; c < txdata_constr.datalen; c++) {
                uint32_t txdata_conv_28 = txdata_vals[c];
-               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
+               void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
+               CHECK_ACCESS(txdata_conv_28_ptr);
+               LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
                txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
                txdata_constr.data[c] = txdata_conv_28_conv;
        }
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14525,9 +16241,15 @@ void  __attribute__((visibility("default"))) TS_ChannelMonitor_transaction_uncon
        CHECK(*((uint32_t*)txid) == 32);
        memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
        unsigned char (*txid_ref)[32] = &txid_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
 }
 
@@ -14539,17 +16261,25 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_best_blo
        CHECK(*((uint32_t*)header) == 80);
        memcpy(header_arr, (uint8_t*)(header + 4), 80);
        unsigned char (*header_ref)[80] = &header_arr;
-       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
+       CHECK_ACCESS(broadcaster_ptr);
+       LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 n = 0; n < ret_var.datalen; n++) {
                LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
                *ret_conv_39_conv = ret_var.data[n];
                ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14559,13 +16289,15 @@ ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -14575,9 +16307,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14589,14 +16322,16 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_clai
        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_tArray ret_arr = NULL;
+       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]);
+               *ret_conv_9_copy = 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;
 }
@@ -14605,7 +16340,9 @@ uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMoni
        LDKu8slice ser_ref;
        ser_ref.datalen = *((uint32_t*)ser);
        ser_ref.data = (int8_t*)(ser + 4);
-       LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
+       void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
+       if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
+       LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
        LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
        *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
        return (uint64_t)ret_conv;
@@ -14657,9 +16394,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txi
        CHECK(*((uint32_t*)txid_arg) == 32);
        memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
        LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14671,9 +16409,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14740,9 +16479,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14798,7 +16538,9 @@ void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_s
        LDKDelayedPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -14864,7 +16606,9 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        LDKPublicKey per_commitment_point_arg_ref;
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
        LDKPublicKey revocation_pubkey_arg_ref;
        CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
@@ -14873,9 +16617,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
        memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14887,9 +16632,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescript
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14928,9 +16674,10 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -14952,7 +16699,9 @@ void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_se
        LDKStaticPaymentOutputDescriptor this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
        val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
        StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
 }
@@ -14996,15 +16745,18 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
        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);
+       void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
+       CHECK_ACCESS(output_arg_ptr);
+       LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
        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);
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15016,9 +16768,10 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15047,7 +16800,9 @@ uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescripto
 
 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SpendableOutputDescriptor_free(this_ptr_conv);
 }
@@ -15065,7 +16820,9 @@ uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_st
        outpoint_conv.inner = (void*)(outpoint & (~1));
        outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
        outpoint_conv = OutPoint_clone(&outpoint_conv);
-       LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
+       void* output_ptr = (void*)(((uint64_t)output) & ~1);
+       CHECK_ACCESS(output_ptr);
+       LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
        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);
@@ -15115,28 +16872,36 @@ uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_re
 
 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        BaseSign_free(this_ptr_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
-       LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSign* orig_conv = (LDKSign*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Sign_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        KeysInterface_free(this_ptr_conv);
 }
@@ -15267,9 +17032,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15299,9 +17065,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_new(int8_tArr
        CHECK(*((uint32_t*)channel_keys_id) == 32);
        memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
        LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15313,9 +17080,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15351,9 +17119,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpo
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15365,9 +17134,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_p
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15412,7 +17182,7 @@ 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_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+       LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
        *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -15421,7 +17191,7 @@ uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint3
        LDKInMemorySigner this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
+       LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
        *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -15459,9 +17229,10 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray
        memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
        unsigned char (*seed_ref)[32] = &seed_arr;
        LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15477,9 +17248,10 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_k
        memcpy(params_arr, (uint8_t*)(params + 4), 32);
        unsigned char (*params_ref)[32] = &params_arr;
        LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15499,7 +17271,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_
        uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
        for (size_t b = 0; b < descriptors_constr.datalen; b++) {
                uint32_t descriptors_conv_27 = descriptors_vals[b];
-               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
+               void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
+               CHECK_ACCESS(descriptors_conv_27_ptr);
+               LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
                descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
                descriptors_constr.data[b] = descriptors_conv_27_conv;
        }
@@ -15512,7 +17286,9 @@ uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_
        uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
        for (size_t h = 0; h < outputs_constr.datalen; h++) {
                uint32_t outputs_conv_7 = outputs_vals[h];
-               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
+               void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
+               CHECK_ACCESS(outputs_conv_7_ptr);
+               LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
                outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
                outputs_constr.data[h] = outputs_conv_7_conv;
        }
@@ -15529,71 +17305,11 @@ 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_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+       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_PaymentId_free(uint32_t this_obj) {
-       LDKPaymentId this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       PaymentId_free(this_obj_conv);
-}
-
-int64_t  __attribute__((visibility("default"))) TS_PaymentId_hash(uint32_t o) {
-       LDKPaymentId o_conv;
-       o_conv.inner = (void*)(o & (~1));
-       o_conv.is_owned = false;
-       int64_t ret_val = PaymentId_hash(&o_conv);
-       return ret_val;
-}
-
-uint32_t  __attribute__((visibility("default"))) TS_PaymentId_clone(uint32_t orig) {
-       LDKPaymentId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKPaymentId ret_var = PaymentId_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;
-}
-
-jboolean  __attribute__((visibility("default"))) TS_PaymentId_eq(uint32_t a, uint32_t b) {
-       LDKPaymentId a_conv;
-       a_conv.inner = (void*)(a & (~1));
-       a_conv.is_owned = false;
-       LDKPaymentId b_conv;
-       b_conv.inner = (void*)(b & (~1));
-       b_conv.is_owned = false;
-       jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
-       return ret_val;
-}
-
-int8_tArray  __attribute__((visibility("default"))) TS_PaymentId_write(uint32_t obj) {
-       LDKPaymentId obj_conv;
-       obj_conv.inner = (void*)(obj & (~1));
-       obj_conv.is_owned = false;
-       LDKCVec_u8Z ret_var = PaymentId_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_PaymentId_read(int8_tArray ser) {
-       LDKu8slice ser_ref;
-       ser_ref.datalen = *((uint32_t*)ser);
-       ser_ref.data = (int8_t*)(ser + 4);
-       LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
-       *ret_conv = PaymentId_read(ser_ref);
-       return (uint64_t)ret_conv;
-}
-
 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
        LDKChannelManager this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -15629,9 +17345,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_blo
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15656,9 +17373,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t
        best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
        best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
        LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15670,9 +17388,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15733,9 +17452,10 @@ void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_c
 
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15747,9 +17467,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15787,9 +17508,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_feat
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15827,11 +17549,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forw
        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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -15860,9 +17585,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15874,9 +17600,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(ui
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15914,9 +17641,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterpa
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -15939,11 +17667,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -15973,7 +17704,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
 }
@@ -16007,7 +17740,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_p
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
 }
@@ -16071,7 +17806,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
 }
@@ -16090,7 +17827,9 @@ void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_s
        LDKChannelDetails this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
        val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
        ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
 }
@@ -16167,17 +17906,26 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArr
        funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
        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);
+       void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
+       CHECK_ACCESS(short_channel_id_arg_ptr);
+       LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
        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);
+       void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
+       CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
+       LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
+       void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
+       CHECK_ACCESS(confirmations_required_arg_ptr);
+       LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
        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);
+       void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
+       CHECK_ACCESS(force_close_spend_delay_arg_ptr);
+       LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
        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_channel_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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16189,9 +17937,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16200,7 +17949,9 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_
 
 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        PaymentSendFailure_free(this_ptr_conv);
 }
@@ -16214,7 +17965,9 @@ 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);
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
        a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
        *ret_copy = PaymentSendFailure_parameter_error(a_conv);
@@ -16232,7 +17985,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_para
        uint32_t* a_vals = (uint32_t*)(a + 4);
        for (size_t w = 0; w < a_constr.datalen; w++) {
                uint32_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
+               void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
+               CHECK_ACCESS(a_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
                a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
                a_constr.data[w] = a_conv_22_conv;
        }
@@ -16252,7 +18007,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_faile
        uint32_t* a_vals = (uint32_t*)(a + 4);
        for (size_t k = 0; k < a_constr.datalen; k++) {
                uint32_t a_conv_10 = a_vals[k];
-               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
+               void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
+               CHECK_ACCESS(a_conv_10_ptr);
+               LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
                a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
                a_constr.data[k] = a_conv_10_conv;
        }
@@ -16262,32 +18019,50 @@ uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_faile
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
-       LDKCVec_CResult_NoneAPIErrorZZ a_constr;
-       a_constr.datalen = *((uint32_t*)a);
-       if (a_constr.datalen > 0)
-               a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
+uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
+       LDKCVec_CResult_NoneAPIErrorZZ results_constr;
+       results_constr.datalen = *((uint32_t*)results);
+       if (results_constr.datalen > 0)
+               results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
        else
-               a_constr.data = NULL;
-       uint32_t* a_vals = (uint32_t*)(a + 4);
-       for (size_t w = 0; w < a_constr.datalen; w++) {
-               uint32_t a_conv_22 = a_vals[w];
-               LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
-               a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
-               a_constr.data[w] = a_conv_22_conv;
-       }
+               results_constr.data = NULL;
+       uint32_t* results_vals = (uint32_t*)(results + 4);
+       for (size_t w = 0; w < results_constr.datalen; w++) {
+               uint32_t results_conv_22 = results_vals[w];
+               void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
+               CHECK_ACCESS(results_conv_22_ptr);
+               LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
+               results_constr.data[w] = results_conv_22_conv;
+       }
+       LDKRouteParameters failed_paths_retry_conv;
+       failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
+       failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
+       failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
-       *ret_copy = PaymentSendFailure_partial_failure(a_constr);
+       *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) {
-       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
+       CHECK_ACCESS(fee_est_ptr);
+       LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKUserConfig config_conv;
        config_conv.inner = (void*)(config & (~1));
        config_conv.is_owned = (config & 1) || (config == 0);
@@ -16297,9 +18072,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t
        params_conv.is_owned = (params & 1) || (params == 0);
        params_conv = ChainParameters_clone(&params_conv);
        LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16311,9 +18087,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_d
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16341,18 +18118,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_cha
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -16362,18 +18142,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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++) {
                LDKChannelDetails ret_conv_16_var = ret_var.data[q];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -16442,19 +18225,18 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, uint32_t payment_id) {
+uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRoute route_conv;
        route_conv.inner = (void*)(route & (~1));
        route_conv.is_owned = false;
-       LDKPaymentId payment_id_conv;
-       payment_id_conv.inner = (void*)(payment_id & (~1));
-       payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
-       payment_id_conv = PaymentId_clone(&payment_id_conv);
+       LDKThirtyTwoBytes payment_id_ref;
+       CHECK(*((uint32_t*)payment_id) == 32);
+       memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
        LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
-       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
+       *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
        return (uint64_t)ret_conv;
 }
 
@@ -16510,7 +18292,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_an
        uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
        for (size_t m = 0; m < addresses_constr.datalen; m++) {
                uint32_t addresses_conv_12 = addresses_vals[m];
-               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
+               void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
+               CHECK_ACCESS(addresses_conv_12_ptr);
+               LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
                addresses_constr.data[m] = addresses_conv_12_conv;
        }
        ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
@@ -16562,21 +18346,13 @@ int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_no
        return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
-       LDKChannelManager this_arg_conv;
-       this_arg_conv.inner = (void*)(this_arg & (~1));
-       this_arg_conv.is_owned = false;
-       LDKOutPoint funding_txo_conv;
-       funding_txo_conv.inner = (void*)(funding_txo & (~1));
-       funding_txo_conv.is_owned = false;
-       ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
        LDKChannelManager this_arg_conv;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
        LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
        *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
@@ -16590,7 +18366,9 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inboun
        LDKThirtyTwoBytes payment_hash_ref;
        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);
+       void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
+       CHECK_ACCESS(min_value_msat_ptr);
+       LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
        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);
@@ -16601,7 +18379,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16610,7 +18388,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProv
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
+       LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
        *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16619,7 +18397,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uin
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
+       LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
        *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16628,7 +18406,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(ui
        LDKChannelManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+       LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
        *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16653,9 +18431,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16666,7 +18445,7 @@ 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_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -16693,7 +18472,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_k
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16701,7 +18481,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
        ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
 }
 
@@ -16709,7 +18491,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_f
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16717,7 +18500,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_e
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
        ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
 }
 
@@ -16725,7 +18510,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_c
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16733,7 +18519,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKWatch val_conv = *(LDKWatch*)(val_ptr);
        ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
 }
 
@@ -16741,7 +18529,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_t
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16749,7 +18538,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_br
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
        ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
 }
 
@@ -16757,7 +18548,8 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_l
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -16765,7 +18557,9 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logge
        LDKChannelManagerReadArgs this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKLogger val_conv = *(LDKLogger*)(val_ptr);
        ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
 }
 
@@ -16774,9 +18568,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_d
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16795,11 +18590,21 @@ void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_defau
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
-       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
-       LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
-       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
+       void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
+       CHECK_ACCESS(fee_estimator_ptr);
+       LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
+       void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
+       CHECK_ACCESS(chain_monitor_ptr);
+       LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
+       void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
+       CHECK_ACCESS(tx_broadcaster_ptr);
+       LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        LDKUserConfig default_config_conv;
        default_config_conv.inner = (void*)(default_config & (~1));
        default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
@@ -16819,9 +18624,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(u
                channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
        }
        LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16853,9 +18659,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16874,9 +18681,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16900,9 +18708,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_a
        features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
        features_arg_conv = InitFeatures_clone(&features_arg_conv);
        LDKInit ret_var = Init_new(features_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16914,9 +18723,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInit ret_var = Init_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16973,9 +18783,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray
        memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
        LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
        LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -16987,9 +18798,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17035,9 +18847,10 @@ void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_
 
 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
        LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17049,9 +18862,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPing ret_var = Ping_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17082,9 +18896,10 @@ void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_
 
 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
        LDKPong ret_var = Pong_new(byteslen_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17096,9 +18911,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPong ret_var = Pong_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17419,9 +19235,10 @@ uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17678,9 +19495,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17777,9 +19595,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArr
        CHECK(*((uint32_t*)signature_arg) == 64);
        memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
        LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17791,9 +19610,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17853,9 +19673,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArra
        CHECK(*((uint32_t*)signature_arg) == 64);
        memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
        LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17867,9 +19688,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17929,9 +19751,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArra
        CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
        memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
        LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -17943,9 +19766,10 @@ uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18008,9 +19832,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray cha
        scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
        LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18022,9 +19847,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdown ret_var = Shutdown_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18070,9 +19896,10 @@ void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fe
 
 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18084,9 +19911,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18158,11 +19986,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -18190,9 +20021,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArra
        fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
        fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
        LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18204,9 +20036,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18308,9 +20141,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18385,9 +20219,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_t
        CHECK(*((uint32_t*)payment_preimage_arg) == 32);
        memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18399,9 +20234,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18454,9 +20290,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18524,9 +20361,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18621,9 +20459,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tA
                htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
        }
        LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18635,9 +20474,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18719,9 +20559,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray
        CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
        memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
        LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18733,9 +20574,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18788,9 +20630,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray ch
        CHECK(*((uint32_t*)channel_id_arg) == 32);
        memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
        LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18802,9 +20645,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t ori
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18864,9 +20708,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tAr
        CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
        memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
        LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18878,9 +20723,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -18948,9 +20794,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uin
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19047,9 +20894,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(i
        CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
        memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19061,9 +20909,10 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19072,7 +20921,9 @@ uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone
 
 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetAddress_free(this_ptr_conv);
 }
@@ -19134,15 +20985,6 @@ int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t
        return ret_arr;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
-       LDKu8slice ser_ref;
-       ser_ref.datalen = *((uint32_t*)ser);
-       ser_ref.data = (int8_t*)(ser + 4);
-       LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
-       *ret_conv = Result_read(ser_ref);
-       return (uint64_t)ret_conv;
-}
-
 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
        LDKu8slice ser_ref;
        ser_ref.datalen = *((uint32_t*)ser);
@@ -19164,9 +21006,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19269,7 +21112,9 @@ void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_add
        uint32_t* val_vals = (uint32_t*)(val + 4);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                uint32_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -19281,9 +21126,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clo
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19321,9 +21167,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_content
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19350,9 +21197,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tA
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
        LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19364,9 +21212,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19385,9 +21234,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19520,9 +21370,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19617,9 +21468,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_cont
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19655,9 +21507,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_new(int8
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19669,9 +21522,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(ui
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19814,9 +21668,10 @@ uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19854,9 +21709,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19883,9 +21739,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArra
        contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
        contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
        LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19897,9 +21754,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19967,9 +21825,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_t
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -19981,9 +21840,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20095,9 +21955,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_new(int8_t
                short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
        }
        LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20109,9 +21970,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20178,9 +22040,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int
                short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
        }
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20192,9 +22055,10 @@ uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20247,9 +22111,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20261,9 +22126,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clon
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20331,9 +22197,10 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(in
        CHECK(*((uint32_t*)chain_hash_arg) == 32);
        memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20345,9 +22212,10 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20356,7 +22224,9 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(
 
 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ErrorAction_free(this_ptr_conv);
 }
@@ -20445,19 +22315,24 @@ void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32
        LDKLightningError this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
        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);
+       void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
+       CHECK_ACCESS(action_arg_ptr);
+       LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
        action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
        LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20469,9 +22344,10 @@ uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKLightningError ret_var = LightningError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20490,18 +22366,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_15_ref = 0;
                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;
+               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;
 }
@@ -20533,18 +22412,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_19_ref = 0;
                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;
+               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;
 }
@@ -20576,18 +22458,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_16_ref = 0;
                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;
+               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;
 }
@@ -20619,18 +22504,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_up
        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_tArray ret_arr = NULL;
+       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];
+               uint64_t ret_conv_25_ref = 0;
                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;
+               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;
 }
@@ -20662,11 +22550,14 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -20687,9 +22578,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitm
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20777,9 +22669,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_new(uint32_
        commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
        commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
        LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20791,9 +22684,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -20802,14 +22696,18 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint3
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        ChannelMessageHandler_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        RoutingMessageHandler_free(this_ptr_conv);
 }
@@ -21464,7 +23362,9 @@ uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(i
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        CustomMessageHandler_free(this_ptr_conv);
 }
@@ -21478,9 +23378,10 @@ void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint
 
 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
        LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21491,7 +23392,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21500,7 +23401,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Ro
        LDKIgnoringMessageHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21509,7 +23410,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Cu
        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");
+       LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21518,7 +23419,7 @@ uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_Cu
        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");
+       LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
        *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21532,9 +23433,10 @@ void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint
 
 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
        LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21545,7 +23447,7 @@ 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_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21554,7 +23456,7 @@ uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_Ch
        LDKErroringMessageHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+       LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
        *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -21570,7 +23472,8 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_hand
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -21578,7 +23481,9 @@ void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
        MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
 }
 
@@ -21586,7 +23491,8 @@ uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_han
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
+       // WARNING: This object doesn't live past this scope, needs clone!
+       uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
        return ret_ret;
 }
 
@@ -21594,17 +23500,24 @@ void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler
        LDKMessageHandler this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
        MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
 }
 
 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
-       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
-       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
+       void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
+       CHECK_ACCESS(chan_handler_arg_ptr);
+       LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
+       void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
+       CHECK_ACCESS(route_handler_arg_ptr);
+       LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
        LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21612,15 +23525,19 @@ 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_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
+       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) {
        if ((this_ptr & 1) != 0) return;
-       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SocketDescriptor_free(this_ptr_conv);
 }
@@ -21649,9 +23566,10 @@ void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connectio
 
 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
        LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21663,9 +23581,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21691,12 +23610,17 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t mes
        CHECK(*((uint32_t*)ephemeral_random_data) == 32);
        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);
-       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
+       CHECK_ACCESS(custom_message_handler_ptr);
+       LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
        LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -21708,13 +23632,15 @@ ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_id
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
-       ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+       ptrArray ret_arr = NULL;
+       ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
        int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
        for (size_t m = 0; m < ret_var.datalen; m++) {
                int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
                memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
                ret_arr_ptr[m] = ret_conv_12_arr;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -21726,7 +23652,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_con
        LDKPublicKey their_node_id_ref;
        CHECK(*((uint32_t*)their_node_id) == 33);
        memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
        *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21736,7 +23664,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_conn
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       CHECK_ACCESS(descriptor_ptr);
+       LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21746,7 +23676,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_spa
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
        *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
        return (uint64_t)ret_conv;
@@ -21756,7 +23688,9 @@ uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint3
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
+       void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
+       if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
+       LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
        LDKu8slice data_ref;
        data_ref.datalen = *((uint32_t*)data);
        data_ref.data = (int8_t*)(data + 4);
@@ -21776,7 +23710,9 @@ void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
+       void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
+       if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
+       LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
        PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
 }
 
@@ -21790,6 +23726,13 @@ void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_i
        PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
 }
 
+void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
+       LDKPeerManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       PeerManager_disconnect_all_peers(&this_arg_conv);
+}
+
 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
        LDKPeerManager this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -21997,9 +23940,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_new(int8_tArr
        CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
        memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
        LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22011,9 +23955,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22159,9 +24104,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_new(int8_t
        CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
        memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22173,9 +24119,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22337,7 +24284,9 @@ void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_trans
        LDKHTLCOutputInCommitment this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
        val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
        HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
 }
@@ -22346,12 +24295,15 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(j
        LDKThirtyTwoBytes payment_hash_arg_ref;
        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);
+       void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
+       CHECK_ACCESS(transaction_output_index_arg_ptr);
+       LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22363,9 +24315,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22453,9 +24406,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22508,11 +24462,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -22533,11 +24490,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -22567,9 +24527,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
        funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22581,9 +24542,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22602,9 +24564,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22643,9 +24606,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
        pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22657,9 +24621,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransacti
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22679,9 +24644,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22693,9 +24659,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22754,9 +24721,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22768,9 +24736,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22798,9 +24767,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionPa
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22859,9 +24829,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22917,9 +24888,10 @@ uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_
        CHECK(*((uint32_t*)counterparty_funding_key) == 33);
        memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
        LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22985,9 +24957,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_n
        CHECK(*((uint32_t*)txid_arg) == 32);
        memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -22999,9 +24972,10 @@ uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_c
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23063,6 +25037,29 @@ void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t
        ClosingTransaction_free(this_obj_conv);
 }
 
+uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone(uint32_t orig) {
+       LDKClosingTransaction orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_hash(uint32_t o) {
+       LDKClosingTransaction o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = ClosingTransaction_hash(&o_conv);
+       return ret_val;
+}
+
 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);
@@ -23077,9 +25074,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23091,9 +25089,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23207,9 +25206,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23273,9 +25273,10 @@ uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23321,9 +25322,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23335,9 +25337,10 @@ uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23420,9 +25423,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23434,9 +25438,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23448,9 +25453,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23462,9 +25468,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23501,9 +25508,10 @@ void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t th
 
 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
        LDKInitFeatures ret_var = InitFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23512,9 +25520,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
        LDKInitFeatures ret_var = InitFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23531,9 +25540,10 @@ jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknow
 
 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
        LDKNodeFeatures ret_var = NodeFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23542,9 +25552,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
        LDKNodeFeatures ret_var = NodeFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23561,9 +25572,10 @@ jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknow
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
        LDKChannelFeatures ret_var = ChannelFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23572,9 +25584,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
        LDKChannelFeatures ret_var = ChannelFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23591,9 +25604,10 @@ jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unk
 
 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23602,9 +25616,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
 
 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
        LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23735,9 +25750,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23778,9 +25794,25 @@ uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(in
        script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
        memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
        LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
+       LDKInvalidShutdownScript orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23813,9 +25845,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(in
        memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
        unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23828,9 +25861,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int
        memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
        unsigned char (*script_hash_ref)[32] = &script_hash_arr;
        LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -23880,65 +25914,108 @@ jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
        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");
+       void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
+       if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
+       LDKType* orig_conv = (LDKType*)orig_ptr;
+       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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Type_free(this_ptr_conv);
 }
 
 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Score_free(this_ptr_conv);
 }
 
-void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
-       LDKNodeId this_obj_conv;
+void  __attribute__((visibility("default"))) TS_LockableScore_free(uint32_t this_obj) {
+       LDKLockableScore this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       NodeId_free(this_obj_conv);
+       LockableScore_free(this_obj_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
-       LDKNodeId orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKNodeId ret_var = NodeId_clone(&orig_conv);
+uint32_t  __attribute__((visibility("default"))) TS_LockableScore_new(uint32_t score) {
+       void* score_ptr = (void*)(((uint64_t)score) & ~1);
+       CHECK_ACCESS(score_ptr);
+       LDKScore score_conv = *(LDKScore*)(score_ptr);
+       LDKLockableScore ret_var = LockableScore_new(score_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
        return ret_ref;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
-       LDKPublicKey pubkey_ref;
-       CHECK(*((uint32_t*)pubkey) == 33);
-       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
-       LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
-       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;
+int8_tArray  __attribute__((visibility("default"))) TS_LockableScore_write(uint32_t obj) {
+       LDKLockableScore obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = LockableScore_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_NodeId_free(uint32_t this_obj) {
+       LDKNodeId this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       NodeId_free(this_obj_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
+       LDKNodeId orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKNodeId ret_var = NodeId_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
 }
 
 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
@@ -23991,9 +26068,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24009,7 +26087,9 @@ void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        NetworkUpdate_free(this_ptr_conv);
 }
@@ -24063,7 +26143,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventH
        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");
+       LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
        *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24075,46 +26155,25 @@ void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t
        NetGraphMsgHandler_free(this_obj_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;
-       if (ret_var.is_owned) {
-               ret_ref |= 1;
-       }
-       return ret_ref;
-}
-
-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);
-       val_conv = NetworkGraph_clone(&val_conv);
-       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);
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       network_graph_conv.is_owned = false;
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24125,7 +26184,9 @@ 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;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -24137,7 +26198,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_Routin
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+       LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
        *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24146,7 +26207,7 @@ uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_Messag
        LDKNetGraphMsgHandler this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
+       LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
        *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -24232,7 +26293,9 @@ void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_
        LDKDirectionalChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -24242,9 +26305,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_f
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24267,11 +26331,14 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_l
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24288,7 +26355,9 @@ 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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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));
@@ -24299,9 +26368,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(i
        last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
        last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24313,9 +26383,10 @@ uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24354,9 +26425,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24379,9 +26451,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24404,11 +26477,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24429,9 +26505,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uin
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24454,11 +26531,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24488,7 +26568,9 @@ void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(ui
        LDKChannelInfo this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
 }
@@ -24498,11 +26580,14 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24539,16 +26624,19 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t fea
        two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
        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);
+       void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
+       CHECK_ACCESS(capacity_sats_arg_ptr);
+       LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
        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);
        announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
        LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24560,9 +26648,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24628,9 +26717,10 @@ void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_mil
 
 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
        LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24653,9 +26743,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24702,9 +26793,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_fea
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24788,7 +26880,9 @@ void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_address
        uint32_t* val_vals = (uint32_t*)(val + 4);
        for (size_t m = 0; m < val_constr.datalen; m++) {
                uint32_t val_conv_12 = val_vals[m];
-               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
+               void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
+               CHECK_ACCESS(val_conv_12_ptr);
+               LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
                val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
                val_constr.data[m] = val_conv_12_conv;
        }
@@ -24800,11 +26894,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_ann
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24840,7 +26937,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uin
        uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
        for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
                uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
-               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
+               CHECK_ACCESS(addresses_arg_conv_12_ptr);
+               LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
                addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
        }
        LDKNodeAnnouncement announcement_message_arg_conv;
@@ -24848,9 +26947,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uin
        announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
        announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24862,9 +26962,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(u
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -24921,11 +27022,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24946,11 +27050,14 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_in
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -24987,9 +27094,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray ch
        announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
        announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
        LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25001,9 +27109,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25055,9 +27164,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray
        CHECK(*((uint32_t*)genesis_hash) == 32);
        memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
        LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25069,9 +27179,10 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25109,7 +27220,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_
        LDKChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -25126,7 +27239,9 @@ uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_
        LDKUnsignedChannelAnnouncement msg_conv;
        msg_conv.inner = (void*)(msg & (~1));
        msg_conv.is_owned = false;
-       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
+       void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
+       CHECK_ACCESS(chain_access_ptr);
+       LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
        // 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
@@ -25221,9 +27336,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(u
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25261,9 +27377,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_feature
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25324,9 +27441,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_new(int8_tArray pub
        channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
        channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
        LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25338,9 +27456,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25398,25 +27517,30 @@ ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t thi
        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");
+       ptrArray ret_arr = NULL;
+       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_tArray ret_conv_12_arr = NULL;
+               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];
+                       uint64_t ret_conv_12_conv_10_ref = 0;
                        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;
+                       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;
 }
@@ -25454,7 +27578,35 @@ void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_pt
        Route_set_paths(&this_ptr_conv, val_constr);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
+uint32_t  __attribute__((visibility("default"))) TS_Route_get_payee(uint32_t this_ptr) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
+       LDKRoute this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       Route_set_payee(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
        LDKCVec_CVec_RouteHopZZ paths_arg_constr;
        paths_arg_constr.datalen = *((uint32_t*)paths_arg);
        if (paths_arg_constr.datalen > 0)
@@ -25481,10 +27633,15 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg
                }
                paths_arg_constr.data[m] = paths_arg_conv_12_constr;
        }
-       LDKRoute ret_var = Route_new(paths_arg_constr);
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25496,9 +27653,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRoute ret_var = Route_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25560,161 +27718,617 @@ uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser)
        return (uint64_t)ret_conv;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
-       LDKRouteHint this_obj_conv;
+void  __attribute__((visibility("default"))) TS_RouteParameters_free(uint32_t this_obj) {
+       LDKRouteParameters this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
        this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       RouteHint_free(this_obj_conv);
+       RouteParameters_free(this_obj_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
-       LDKRouteHint orig_conv;
-       orig_conv.inner = (void*)(orig & (~1));
-       orig_conv.is_owned = false;
-       LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
        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;
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKPayee val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = Payee_clone(&val_conv);
+       RouteParameters_set_payee(&this_ptr_conv, val_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);
+int64_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_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));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       RouteHintHop_free(this_obj_conv);
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
+       LDKRouteParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteParameters_set_final_value_msat(&this_ptr_conv, val);
 }
 
-int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+int32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
+       LDKRouteParameters 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), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
-       return ret_arr;
+       int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
+       LDKRouteParameters 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);
-       RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
+       RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
 }
 
-int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
+       LDKPayee payee_arg_conv;
+       payee_arg_conv.inner = (void*)(payee_arg & (~1));
+       payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
+       payee_arg_conv = Payee_clone(&payee_arg_conv);
+       LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_clone(uint32_t orig) {
+       LDKRouteParameters orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteParameters_write(uint32_t obj) {
+       LDKRouteParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteParameters_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_RouteParameters_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
+       *ret_conv = RouteParameters_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_Payee_free(uint32_t this_obj) {
+       LDKPayee this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Payee_free(this_obj_conv);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
-       return ret_val;
+       int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+       memcpy((uint8_t*)(ret_arr + 4), Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
+       LDKPublicKey val_ref;
+       CHECK(*((uint32_t*)val) == 33);
+       memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
+       Payee_set_pubkey(&this_ptr_conv, val_ref);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_get_features(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingFees ret_var = RouteHintHop_get_fees(&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;
+       LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKRoutingFees val_conv;
+       LDKInvoiceFeatures val_conv;
        val_conv.inner = (void*)(val & (~1));
        val_conv.is_owned = (val & 1) || (val == 0);
-       val_conv = RoutingFees_clone(&val_conv);
-       RouteHintHop_set_fees(&this_ptr_conv, val_conv);
+       val_conv = InvoiceFeatures_clone(&val_conv);
+       Payee_set_features(&this_ptr_conv, val_conv);
 }
 
-int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_tArray  __attribute__((visibility("default"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
-       return ret_val;
+       LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
+       uint32_tArray ret_arr = NULL;
+       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 l = 0; l < ret_var.datalen; l++) {
+               LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
+               CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               if (ret_conv_11_var.is_owned) {
+                       ret_conv_11_ref |= 1;
+               }
+               ret_arr_ptr[l] = ret_conv_11_ref;
+       }
+       
+       FREE(ret_var.data);
+       return ret_arr;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
+       LDKCVec_RouteHintZ val_constr;
+       val_constr.datalen = *((uint32_t*)val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               val_constr.data = NULL;
+       uint32_t* val_vals = (uint32_t*)(val + 4);
+       for (size_t l = 0; l < val_constr.datalen; l++) {
+               uint32_t val_conv_11 = val_vals[l];
+               LDKRouteHint val_conv_11_conv;
+               val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
+               val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
+               val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
+               val_constr.data[l] = val_conv_11_conv;
+       }
+       Payee_set_route_hints(&this_ptr_conv, val_constr);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
+       *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
 
-void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
-       LDKRouteHintHop this_ptr_conv;
+void  __attribute__((visibility("default"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
+       LDKPayee this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
-       RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
+       Payee_set_expiry_time(&this_ptr_conv, val_conv);
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
-       LDKRouteHintHop this_ptr_conv;
-       this_ptr_conv.inner = (void*)(this_ptr & (~1));
-       this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
-       uint64_t ret_ref = (uint64_t)ret_copy;
-       return ret_ref;
+uint32_t  __attribute__((visibility("default"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
+       LDKPublicKey pubkey_arg_ref;
+       CHECK(*((uint32_t*)pubkey_arg) == 33);
+       memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
+       LDKInvoiceFeatures 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 = InvoiceFeatures_clone(&features_arg_conv);
+       LDKCVec_RouteHintZ route_hints_arg_constr;
+       route_hints_arg_constr.datalen = *((uint32_t*)route_hints_arg);
+       if (route_hints_arg_constr.datalen > 0)
+               route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
+       else
+               route_hints_arg_constr.data = NULL;
+       uint32_t* route_hints_arg_vals = (uint32_t*)(route_hints_arg + 4);
+       for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
+               uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
+               LDKRouteHint route_hints_arg_conv_11_conv;
+               route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
+               route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
+               route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
+               route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
+       }
+       void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
+       CHECK_ACCESS(expiry_time_arg_ptr);
+       LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
+       expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
+       LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_clone(uint32_t orig) {
+       LDKPayee orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKPayee ret_var = Payee_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_Payee_hash(uint32_t o) {
+       LDKPayee o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = Payee_hash(&o_conv);
+       return ret_val;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_Payee_eq(uint32_t a, uint32_t b) {
+       LDKPayee a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKPayee b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = Payee_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_Payee_write(uint32_t obj) {
+       LDKPayee obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Payee_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_Payee_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
+       *ret_conv = Payee_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_from_node_id(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_Payee_for_keysend(int8_tArray pubkey) {
+       LDKPublicKey pubkey_ref;
+       CHECK(*((uint32_t*)pubkey) == 33);
+       memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
+       LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
+       LDKRouteHint this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteHint_free(this_obj_conv);
+}
+
+uint32_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_a(uint32_t this_ptr) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
+               LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
+               CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+               CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               if (ret_conv_14_var.is_owned) {
+                       ret_conv_14_ref |= 1;
+               }
+               ret_arr_ptr[o] = ret_conv_14_ref;
+       }
+       
+       FREE(ret_var.data);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
+       LDKRouteHint this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCVec_RouteHintHopZ val_constr;
+       val_constr.datalen = *((uint32_t*)val);
+       if (val_constr.datalen > 0)
+               val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               val_constr.data = NULL;
+       uint32_t* val_vals = (uint32_t*)(val + 4);
+       for (size_t o = 0; o < val_constr.datalen; o++) {
+               uint32_t val_conv_14 = val_vals[o];
+               LDKRouteHintHop val_conv_14_conv;
+               val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
+               val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
+               val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
+               val_constr.data[o] = val_conv_14_conv;
+       }
+       RouteHint_set_a(&this_ptr_conv, val_constr);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(uint32_tArray a_arg) {
+       LDKCVec_RouteHintHopZ a_arg_constr;
+       a_arg_constr.datalen = *((uint32_t*)a_arg);
+       if (a_arg_constr.datalen > 0)
+               a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
+       else
+               a_arg_constr.data = NULL;
+       uint32_t* a_arg_vals = (uint32_t*)(a_arg + 4);
+       for (size_t o = 0; o < a_arg_constr.datalen; o++) {
+               uint32_t a_arg_conv_14 = a_arg_vals[o];
+               LDKRouteHintHop a_arg_conv_14_conv;
+               a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
+               a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
+               a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
+               a_arg_constr.data[o] = a_arg_conv_14_conv;
+       }
+       LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
+       LDKRouteHint orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       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;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_write(uint32_t obj) {
+       LDKRouteHint obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHint_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_RouteHint_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
+       *ret_conv = RouteHint_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
+       LDKRouteHintHop this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RouteHintHop_free(this_obj_conv);
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
+       LDKRouteHintHop 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), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
+       LDKRouteHintHop 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);
+       RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKRoutingFees val_conv;
+       val_conv.inner = (void*)(val & (~1));
+       val_conv.is_owned = (val & 1) || (val == 0);
+       val_conv = RoutingFees_clone(&val_conv);
+       RouteHintHop_set_fees(&this_ptr_conv, val_conv);
+}
+
+int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
+       val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
+       RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
+       LDKRouteHintHop this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
+       *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
 }
 
 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
        LDKRouteHintHop this_ptr_conv;
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
-       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
+       void* val_ptr = (void*)(((uint64_t)val) & ~1);
+       CHECK_ACCESS(val_ptr);
+       LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
        val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
        RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
 }
@@ -25727,14 +28341,19 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray
        fees_arg_conv.inner = (void*)(fees_arg & (~1));
        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);
+       void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
        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);
+       void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
+       CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
+       LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25746,9 +28365,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25774,71 +28394,36 @@ jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a,
        return ret_val;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_pubkey, 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, uint32_t scorer) {
-       LDKPublicKey our_node_pubkey_ref;
-       CHECK(*((uint32_t*)our_node_pubkey) == 33);
-       memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
-       LDKNetworkGraph network_conv;
-       network_conv.inner = (void*)(network & (~1));
-       network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK(*((uint32_t*)payee) == 33);
-       memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
-       LDKCVec_ChannelDetailsZ first_hops_constr;
-       LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
-       if (first_hops != 0) {
-               first_hops_constr.datalen = *((uint32_t*)first_hops);
-               if (first_hops_constr.datalen > 0)
-                       first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
-               else
-                       first_hops_constr.data = NULL;
-               uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
-               for (size_t q = 0; q < first_hops_constr.datalen; q++) {
-                       uint32_t first_hops_conv_16 = first_hops_vals[q];
-                       LDKChannelDetails first_hops_conv_16_conv;
-                       first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
-                       first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
-                       first_hops_constr.data[q] = first_hops_conv_16_conv;
-               }
-               first_hops_ptr = &first_hops_constr;
-       }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = *((uint32_t*)last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               uint32_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
-       LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
-       if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
+int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_write(uint32_t obj) {
+       LDKRouteHintHop obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = RouteHintHop_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_RouteHintHop_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
+       *ret_conv = RouteHintHop_read(ser_ref);
        return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_pubkey, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger, uint32_t scorer) {
+uint32_t  __attribute__((visibility("default"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
        LDKPublicKey our_node_pubkey_ref;
        CHECK(*((uint32_t*)our_node_pubkey) == 33);
        memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
+       LDKRouteParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = false;
        LDKNetworkGraph network_conv;
        network_conv.inner = (void*)(network & (~1));
        network_conv.is_owned = false;
-       LDKPublicKey payee_ref;
-       CHECK(*((uint32_t*)payee) == 33);
-       memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
-       LDKInvoiceFeatures payee_features_conv;
-       payee_features_conv.inner = (void*)(payee_features & (~1));
-       payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
-       payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
        LDKCVec_ChannelDetailsZ first_hops_constr;
        LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
        if (first_hops != 0) {
@@ -25857,41 +28442,119 @@ uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_no
                }
                first_hops_ptr = &first_hops_constr;
        }
-       LDKCVec_RouteHintZ last_hops_constr;
-       last_hops_constr.datalen = *((uint32_t*)last_hops);
-       if (last_hops_constr.datalen > 0)
-               last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
-       else
-               last_hops_constr.data = NULL;
-       uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
-       for (size_t l = 0; l < last_hops_constr.datalen; l++) {
-               uint32_t last_hops_conv_11 = last_hops_vals[l];
-               LDKRouteHint last_hops_conv_11_conv;
-               last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
-               last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
-               last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
-               last_hops_constr.data[l] = last_hops_conv_11_conv;
-       }
-       LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
-       LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
+       if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
+       LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
        LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
-       *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
+       *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
        if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
        return (uint64_t)ret_conv;
 }
 
-void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
-       LDKScorer this_obj_conv;
-       this_obj_conv.inner = (void*)(this_obj & (~1));
-       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
-       Scorer_free(this_obj_conv);
+void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
+       LDKScorer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       Scorer_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_free(uint32_t this_obj) {
+       LDKScoringParameters this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       ScoringParameters_free(this_obj_conv);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
+       LDKScoringParameters this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
+       LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+int8_tArray  __attribute__((visibility("default"))) TS_ScoringParameters_write(uint32_t obj) {
+       LDKScoringParameters obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = ScoringParameters_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_ScoringParameters_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
+       *ret_conv = ScoringParameters_read(ser_ref);
+       return (uint64_t)ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(int64_t base_penalty_msat) {
-       LDKScorer ret_var = Scorer_new(base_penalty_msat);
+uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(uint32_t params) {
+       LDKScoringParameters params_conv;
+       params_conv.inner = (void*)(params & (~1));
+       params_conv.is_owned = (params & 1) || (params == 0);
+       // Warning: we need a move here but no clone is available for LDKScoringParameters
+       LDKScorer ret_var = Scorer_new(params_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25900,9 +28563,22 @@ uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(int64_t base_pena
 
 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
        LDKScorer ret_var = Scorer_default();
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_default() {
+       LDKScoringParameters ret_var = ScoringParameters_default();
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25913,11 +28589,31 @@ uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t thi
        LDKScorer this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
+       LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
        *ret_ret = Scorer_as_Score(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
 
+int8_tArray  __attribute__((visibility("default"))) TS_Scorer_write(uint32_t obj) {
+       LDKScorer obj_conv;
+       obj_conv.inner = (void*)(obj & (~1));
+       obj_conv.is_owned = false;
+       LDKCVec_u8Z ret_var = Scorer_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_Scorer_read(int8_tArray ser) {
+       LDKu8slice ser_ref;
+       ser_ref.datalen = *((uint32_t*)ser);
+       ser_ref.data = (int8_t*)(ser + 4);
+       LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
+       *ret_conv = Scorer_read(ser_ref);
+       return (uint64_t)ret_conv;
+}
+
 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
        LDKFilesystemPersister this_obj_conv;
        this_obj_conv.inner = (void*)(this_obj & (~1));
@@ -25928,9 +28624,10 @@ void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_
 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
        LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
        LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -25961,7 +28658,9 @@ uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_cha
        LDKFilesystemPersister this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
        *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
        return (uint64_t)ret_conv;
@@ -25971,7 +28670,7 @@ 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_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
+       LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
        *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
        return (uint64_t)ret_ret;
 }
@@ -25985,14 +28684,20 @@ void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_
 
 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        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 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);
+       void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
+       CHECK_ACCESS(persister_ptr);
+       LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
        LDKChainMonitor chain_monitor_conv;
        chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
        chain_monitor_conv.is_owned = false;
@@ -26005,11 +28710,14 @@ uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(ui
        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);
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
        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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26063,9 +28771,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig)
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoice ret_var = Invoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26095,9 +28804,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26116,9 +28826,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26152,9 +28863,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26173,9 +28885,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(ui
        this_ptr_conv.inner = (void*)(this_ptr & (~1));
        this_ptr_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26209,9 +28922,10 @@ uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26241,9 +28955,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26345,9 +29060,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig)
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKSha256 ret_var = Sha256_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26385,9 +29101,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t o
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKDescription ret_var = Description_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26420,14 +29137,49 @@ void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_o
        PayeePubKey_free(this_obj_conv);
 }
 
+int8_tArray  __attribute__((visibility("default"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
+       LDKPayeePubKey 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), PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
+       return ret_arr;
+}
+
+void  __attribute__((visibility("default"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
+       LDKPayeePubKey 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);
+       PayeePubKey_set_a(&this_ptr_conv, val_ref);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_new(int8_tArray a_arg) {
+       LDKPublicKey a_arg_ref;
+       CHECK(*((uint32_t*)a_arg) == 33);
+       memcpy(a_arg_ref.compressed_form, (uint8_t*)(a_arg + 4), 33);
+       LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 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;
        LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26465,9 +29217,10 @@ uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t or
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26500,14 +29253,42 @@ void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t
        MinFinalCltvExpiry_free(this_obj_conv);
 }
 
+int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
+       LDKMinFinalCltvExpiry this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
+       LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
 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);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26535,7 +29316,9 @@ jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32
 
 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);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        Fallback_free(this_ptr_conv);
 }
@@ -26605,9 +29388,10 @@ uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint3
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26637,9 +29421,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t
        orig_conv.inner = (void*)(orig & (~1));
        orig_conv.is_owned = false;
        LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26680,9 +29465,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26703,9 +29489,10 @@ uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(u
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26743,11 +29530,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_payment_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26757,11 +29547,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKDescription ret_var = RawInvoice_description(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26771,11 +29564,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26785,11 +29581,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKSha256 ret_var = RawInvoice_description_hash(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26799,11 +29598,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint3
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKExpiryTime ret_var = RawInvoice_expiry_time(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26813,11 +29615,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_ex
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26836,11 +29641,14 @@ uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = RawInvoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -26850,18 +29658,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_rout
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -26918,9 +29729,10 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = Invoice_clone(&this_arg_conv);
        LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -26977,7 +29789,7 @@ int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(ui
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
-       memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
+       memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_secret(&this_arg_conv), 32);
        return ret_arr;
 }
 
@@ -26986,11 +29798,14 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t th
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKInvoiceFeatures ret_var = Invoice_features(&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;
+       uint64_t ret_ref = 0;
+       if ((uint64_t)ret_var.inner > 4096) {
+               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.
+               ret_ref = (uint64_t)ret_var.inner;
+               if (ret_var.is_owned) {
+                       ret_ref |= 1;
+               }
        }
        return ret_ref;
 }
@@ -27012,6 +29827,14 @@ int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t
        return ret_val;
 }
 
+jboolean  __attribute__((visibility("default"))) TS_Invoice_is_expired(uint32_t this_arg) {
+       LDKInvoice this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       jboolean ret_val = Invoice_is_expired(&this_arg_conv);
+       return ret_val;
+}
+
 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
@@ -27025,18 +29848,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 o = 0; o < ret_var.datalen; o++) {
                LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
+               uint64_t ret_conv_14_ref = 0;
                CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
+               ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
                if (ret_conv_14_var.is_owned) {
                        ret_conv_14_ref |= 1;
                }
                ret_arr_ptr[o] = ret_conv_14_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -27046,18 +29872,21 @@ uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uin
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
-       uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+       uint32_tArray ret_arr = NULL;
+       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 l = 0; l < ret_var.datalen; l++) {
                LDKRouteHint ret_conv_11_var = ret_var.data[l];
+               uint64_t ret_conv_11_ref = 0;
                CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
                CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
-               uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
+               ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
                if (ret_conv_11_var.is_owned) {
                        ret_conv_11_ref |= 1;
                }
                ret_arr_ptr[l] = ret_conv_11_ref;
        }
+       
        FREE(ret_var.data);
        return ret_arr;
 }
@@ -27070,12 +29899,12 @@ uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t th
        return ret_conv;
 }
 
-uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
+uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
        LDKInvoice this_arg_conv;
        this_arg_conv.inner = (void*)(this_arg & (~1));
        this_arg_conv.is_owned = false;
        LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
-       *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
+       *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
        uint64_t ret_ref = (uint64_t)ret_copy;
        return ret_ref;
 }
@@ -27142,9 +29971,10 @@ uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint
        this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
        this_arg_conv = PrivateRoute_clone(&this_arg_conv);
        LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
+       uint64_t ret_ref = 0;
        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;
+       ret_ref = (uint64_t)ret_var.inner;
        if (ret_var.is_owned) {
                ret_ref |= 1;
        }
@@ -27265,7 +30095,9 @@ jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t
 
 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
        if ((this_ptr & 1) != 0) return;
-       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
        FREE((void*)this_ptr);
        SignOrCreationError_free(this_ptr_conv);
 }
@@ -27308,13 +30140,232 @@ jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(ui
        return ret_conv;
 }
 
+void  __attribute__((visibility("default"))) TS_InvoicePayer_free(uint32_t this_obj) {
+       LDKInvoicePayer this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       InvoicePayer_free(this_obj_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_Payer_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Payer_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_Router_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       Router_free(this_ptr_conv);
+}
+
+void  __attribute__((visibility("default"))) TS_RetryAttempts_free(uint32_t this_obj) {
+       LDKRetryAttempts this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       RetryAttempts_free(this_obj_conv);
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_RetryAttempts_set_a(uint32_t this_ptr, int64_t val) {
+       LDKRetryAttempts this_ptr_conv;
+       this_ptr_conv.inner = (void*)(this_ptr & (~1));
+       this_ptr_conv.is_owned = false;
+       RetryAttempts_set_a(&this_ptr_conv, val);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_new(int64_t a_arg) {
+       LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone(uint32_t orig) {
+       LDKRetryAttempts orig_conv;
+       orig_conv.inner = (void*)(orig & (~1));
+       orig_conv.is_owned = false;
+       LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+jboolean  __attribute__((visibility("default"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
+       LDKRetryAttempts a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = false;
+       LDKRetryAttempts b_conv;
+       b_conv.inner = (void*)(b & (~1));
+       b_conv.is_owned = false;
+       jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
+       return ret_val;
+}
+
+int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_hash(uint32_t o) {
+       LDKRetryAttempts o_conv;
+       o_conv.inner = (void*)(o & (~1));
+       o_conv.is_owned = false;
+       int64_t ret_val = RetryAttempts_hash(&o_conv);
+       return ret_val;
+}
+
+void  __attribute__((visibility("default"))) TS_PaymentError_free(uint32_t this_ptr) {
+       if ((this_ptr & 1) != 0) return;
+       void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
+       CHECK_ACCESS(this_ptr_ptr);
+       LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
+       FREE((void*)this_ptr);
+       PaymentError_free(this_ptr_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_clone(uint32_t orig) {
+       LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_clone(orig_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_invoice(jstring a) {
+       LDKStr a_conv = str_ref_to_owned_c(a);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_invoice(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_routing(uint32_t a) {
+       LDKLightningError a_conv;
+       a_conv.inner = (void*)(a & (~1));
+       a_conv.is_owned = (a & 1) || (a == 0);
+       a_conv = LightningError_clone(&a_conv);
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_routing(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_PaymentError_sending(uint32_t a) {
+       void* a_ptr = (void*)(((uint64_t)a) & ~1);
+       CHECK_ACCESS(a_ptr);
+       LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
+       a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
+       LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
+       *ret_copy = PaymentError_sending(a_conv);
+       uint64_t ret_ref = (uint64_t)ret_copy;
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
+       void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
+       CHECK_ACCESS(payer_ptr);
+       LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
+       void* router_ptr = (void*)(((uint64_t)router) & ~1);
+       CHECK_ACCESS(router_ptr);
+       LDKRouter router_conv = *(LDKRouter*)(router_ptr);
+       LDKLockableScore scorer_conv;
+       scorer_conv.inner = (void*)(scorer & (~1));
+       scorer_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
+       CHECK_ACCESS(event_handler_ptr);
+       LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
+       LDKRetryAttempts retry_attempts_conv;
+       retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
+       retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
+       retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
+       LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
+       return (uint64_t)ret_conv;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKInvoice invoice_conv;
+       invoice_conv.inner = (void*)(invoice & (~1));
+       invoice_conv.is_owned = false;
+       LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
+       *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
+       return (uint64_t)ret_conv;
+}
+
+void  __attribute__((visibility("default"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
+       LDKInvoicePayer this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       unsigned char payment_hash_arr[32];
+       CHECK(*((uint32_t*)payment_hash) == 32);
+       memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
+       unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
+       InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
+       LDKInvoicePayer 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 = InvoicePayer_as_EventHandler(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelmanager(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description) {
        LDKChannelManager channelmanager_conv;
        channelmanager_conv.inner = (void*)(channelmanager & (~1));
        channelmanager_conv.is_owned = false;
-       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
+       void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
+       CHECK_ACCESS(keys_manager_ptr);
+       LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
        LDKCurrency network_conv = LDKCurrency_from_js(network);
-       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
+       void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
+       CHECK_ACCESS(amt_msat_ptr);
+       LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
        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");
@@ -27322,6 +30373,49 @@ uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelm
        return (uint64_t)ret_conv;
 }
 
+void  __attribute__((visibility("default"))) TS_DefaultRouter_free(uint32_t this_obj) {
+       LDKDefaultRouter this_obj_conv;
+       this_obj_conv.inner = (void*)(this_obj & (~1));
+       this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
+       DefaultRouter_free(this_obj_conv);
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
+       LDKNetworkGraph network_graph_conv;
+       network_graph_conv.inner = (void*)(network_graph & (~1));
+       network_graph_conv.is_owned = false;
+       void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
+       CHECK_ACCESS(logger_ptr);
+       LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
+       LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
+       uint64_t ret_ref = 0;
+       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.
+       ret_ref = (uint64_t)ret_var.inner;
+       if (ret_var.is_owned) {
+               ret_ref |= 1;
+       }
+       return ret_ref;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
+       LDKDefaultRouter this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
+       *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
+uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
+       LDKChannelManager this_arg_conv;
+       this_arg_conv.inner = (void*)(this_arg & (~1));
+       this_arg_conv.is_owned = false;
+       LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
+       *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
+       return (uint64_t)ret_ret;
+}
+
 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
        LDKStr s_conv = str_ref_to_owned_c(s);
        LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
index 0310e0a33a9e65a47078ad8eb20e580c62f48731..1257092210a1eeebf8e956a4b0225e1414e22c54 100644 (file)
@@ -239,6 +239,10 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_RouteDecodeErrorZ_result_ok(long arg);
        public static native number LDKCResult_RouteDecodeErrorZ_get_ok(long arg);
        public static native number LDKCResult_RouteDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_RouteParametersDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_RouteParametersDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_RouteParametersDecodeErrorZ_get_err(long arg);
+       public static native long LDKCVec_RouteHintZ_new(number[] elems);
        public static class LDKCOption_u64Z {
                private LDKCOption_u64Z() {}
                export class Some extends LDKCOption_u64Z {
@@ -252,15 +256,23 @@ public static native long new_empty_slice_vec();
        }
        static { LDKCOption_u64Z.init(); }
        public static native LDKCOption_u64Z LDKCOption_u64Z_ref_from_ptr(long ptr);
+       public static native boolean LDKCResult_PayeeDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_PayeeDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_PayeeDecodeErrorZ_get_err(long arg);
+       public static native long LDKCVec_RouteHintHopZ_new(number[] elems);
+       public static native boolean LDKCResult_RouteHintDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_RouteHintDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_RouteHintDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_RouteHintHopDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_RouteHintHopDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_RouteHintHopDecodeErrorZ_get_err(long arg);
        public static native long LDKCVec_ChannelDetailsZ_new(number[] elems);
-       public static native long LDKCVec_RouteHintZ_new(number[] elems);
        public static native boolean LDKCResult_RouteLightningErrorZ_result_ok(long arg);
        public static native number LDKCResult_RouteLightningErrorZ_get_ok(long arg);
        public static native number LDKCResult_RouteLightningErrorZ_get_err(long arg);
        public static native boolean LDKCResult_TxOutAccessErrorZ_result_ok(long arg);
        public static native number LDKCResult_TxOutAccessErrorZ_get_ok(long arg);
        public static native AccessError LDKCResult_TxOutAccessErrorZ_get_err(long arg);
-       public static native long LDKC2Tuple_usizeTransactionZ_new(number a, Uint8Array b);
        // uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple);
        export function C2Tuple_usizeTransactionZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -291,6 +303,15 @@ public static native long new_empty_slice_vec();
                        public number commitment_tx_confirmed;
                        CommitmentTxConfirmed(number commitment_tx_confirmed) { this.commitment_tx_confirmed = commitment_tx_confirmed; }
                }
+               export class UpdateCompleted extends LDKMonitorEvent {
+                       public number funding_txo;
+                       public number monitor_update_id;
+                       UpdateCompleted(number funding_txo, number monitor_update_id) { this.funding_txo = funding_txo; this.monitor_update_id = monitor_update_id; }
+               }
+               export class UpdateFailed extends LDKMonitorEvent {
+                       public number update_failed;
+                       UpdateFailed(number update_failed) { this.update_failed = update_failed; }
+               }
                static native void init();
        }
        static { LDKMonitorEvent.init(); }
@@ -495,6 +516,12 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(long arg);
        public static native number LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(long arg);
        public static native number LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_ScoringParametersDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_ScoringParametersDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_ScoringParametersDecodeErrorZ_get_err(long arg);
+       public static native boolean LDKCResult_ScorerDecodeErrorZ_result_ok(long arg);
+       public static native number LDKCResult_ScorerDecodeErrorZ_get_ok(long arg);
+       public static native number LDKCResult_ScorerDecodeErrorZ_get_err(long arg);
        public static native boolean LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(long arg);
        public static native number LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(long arg);
        public static native number LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(long arg);
@@ -507,7 +534,6 @@ public static native long new_empty_slice_vec();
        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);
        // struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple);
        export function C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -710,7 +736,6 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_TransactionNoneZ_result_ok(long arg);
        public static native Uint8Array LDKCResult_TransactionNoneZ_get_ok(long arg);
        public static native void LDKCResult_TransactionNoneZ_get_err(long arg);
-       public static native long LDKC2Tuple_BlockHashChannelMonitorZ_new(Uint8Array a, number b);
        // struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple);
        export function C2Tuple_BlockHashChannelMonitorZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -731,9 +756,6 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(long arg);
        public static native number[] LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(long arg);
        public static native IOError LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(long arg);
-       public static native boolean LDKCResult_PaymentIdDecodeErrorZ_result_ok(long arg);
-       public static native number LDKCResult_PaymentIdDecodeErrorZ_get_ok(long arg);
-       public static native number LDKCResult_PaymentIdDecodeErrorZ_get_err(long arg);
        public static class LDKCOption_u16Z {
                private LDKCOption_u16Z() {}
                export class Some extends LDKCOption_u16Z {
@@ -800,20 +822,21 @@ public static native long new_empty_slice_vec();
                        AllFailedRetrySafe(number[] all_failed_retry_safe) { this.all_failed_retry_safe = all_failed_retry_safe; }
                }
                export class PartialFailure extends LDKPaymentSendFailure {
-                       public number[] partial_failure;
-                       PartialFailure(number[] partial_failure) { this.partial_failure = partial_failure; }
+                       public number[] results;
+                       public number failed_paths_retry;
+                       public Uint8Array payment_id;
+                       PartialFailure(number[] results, number failed_paths_retry, Uint8Array payment_id) { this.results = results; this.failed_paths_retry = failed_paths_retry; this.payment_id = payment_id; }
                }
                static native void init();
        }
        static { LDKPaymentSendFailure.init(); }
        public static native LDKPaymentSendFailure LDKPaymentSendFailure_ref_from_ptr(long ptr);
        public static native boolean LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(long arg);
-       public static native number LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(long arg);
+       public static native Uint8Array LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(long arg);
        public static native number LDKCResult_PaymentIdPaymentSendFailureZ_get_err(long arg);
        public static native boolean LDKCResult_NonePaymentSendFailureZ_result_ok(long arg);
        public static native void LDKCResult_NonePaymentSendFailureZ_get_ok(long arg);
        public static native number LDKCResult_NonePaymentSendFailureZ_get_err(long arg);
-       public static native long LDKC2Tuple_PaymentHashPaymentIdZ_new(Uint8Array a, number b);
        // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
        export function C2Tuple_PaymentHashPaymentIdZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -822,13 +845,13 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.C2Tuple_PaymentHashPaymentIdZ_get_a(tuple);
                return decodeArray(nativeResponseValue);
        }
-       // struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
-       export function C2Tuple_PaymentHashPaymentIdZ_get_b(tuple: number): number {
+       // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple);
+       export function C2Tuple_PaymentHashPaymentIdZ_get_b(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
                const nativeResponseValue = wasm.C2Tuple_PaymentHashPaymentIdZ_get_b(tuple);
-               return nativeResponseValue;
+               return decodeArray(nativeResponseValue);
        }
        public static native boolean LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(long arg);
        public static native number LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(long arg);
@@ -862,7 +885,6 @@ public static native long new_empty_slice_vec();
        static { LDKNetAddress.init(); }
        public static native LDKNetAddress LDKNetAddress_ref_from_ptr(long ptr);
        public static native long LDKCVec_NetAddressZ_new(number[] elems);
-       public static native long LDKC2Tuple_PaymentHashPaymentSecretZ_new(Uint8Array a, Uint8Array b);
        // struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple);
        export function C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -1067,7 +1089,6 @@ public static native long new_empty_slice_vec();
 // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END
 
 
-       public static native long LDKC2Tuple_BlockHashChannelManagerZ_new(Uint8Array a, number b);
        // struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple);
        export function C2Tuple_BlockHashChannelManagerZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -1151,6 +1172,27 @@ public static native long new_empty_slice_vec();
        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 class LDKPaymentError {
+               private LDKPaymentError() {}
+               export class Invoice extends LDKPaymentError {
+                       public String invoice;
+                       Invoice(String invoice) { this.invoice = invoice; }
+               }
+               export class Routing extends LDKPaymentError {
+                       public number routing;
+                       Routing(number routing) { this.routing = routing; }
+               }
+               export class Sending extends LDKPaymentError {
+                       public number sending;
+                       Sending(number sending) { this.sending = sending; }
+               }
+               static native void init();
+       }
+       static { LDKPaymentError.init(); }
+       public static native LDKPaymentError LDKPaymentError_ref_from_ptr(long ptr);
+       public static native boolean LDKCResult_PaymentIdPaymentErrorZ_result_ok(long arg);
+       public static native Uint8Array LDKCResult_PaymentIdPaymentErrorZ_get_ok(long arg);
+       public static native number LDKCResult_PaymentIdPaymentErrorZ_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);
@@ -1160,7 +1202,6 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_SignedRawInvoiceNoneZ_result_ok(long arg);
        public static native number LDKCResult_SignedRawInvoiceNoneZ_get_ok(long arg);
        public static native void LDKCResult_SignedRawInvoiceNoneZ_get_err(long arg);
-       public static native long LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(number a, Uint8Array b, number c);
        // struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple);
        export function C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -1219,7 +1260,6 @@ public static native long new_empty_slice_vec();
        public static native boolean LDKCResult_NoneMonitorUpdateErrorZ_result_ok(long arg);
        public static native void LDKCResult_NoneMonitorUpdateErrorZ_get_ok(long arg);
        public static native number LDKCResult_NoneMonitorUpdateErrorZ_get_err(long arg);
-       public static native long LDKC2Tuple_OutPointScriptZ_new(number a, Uint8Array b);
        // struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple);
        export function C2Tuple_OutPointScriptZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -1236,7 +1276,6 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.C2Tuple_OutPointScriptZ_get_b(tuple);
                return decodeArray(nativeResponseValue);
        }
-       public static native long LDKC2Tuple_u32ScriptZ_new(number a, Uint8Array b);
        // uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple);
        export function C2Tuple_u32ScriptZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -1254,7 +1293,6 @@ public static native long new_empty_slice_vec();
                return decodeArray(nativeResponseValue);
        }
        public static native long LDKCVec_C2Tuple_u32ScriptZZ_new(number[] elems);
-       public static native long LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(Uint8Array a, number[] b);
        // struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple);
        export function C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -1333,18 +1371,22 @@ public static native long new_empty_slice_vec();
                        PaymentReceived(Uint8Array payment_hash, number amt, number purpose) { this.payment_hash = payment_hash; this.amt = amt; this.purpose = purpose; }
                }
                export class PaymentSent extends LDKEvent {
+                       public Uint8Array payment_id;
                        public Uint8Array payment_preimage;
                        public Uint8Array payment_hash;
-                       PaymentSent(Uint8Array payment_preimage, Uint8Array payment_hash) { this.payment_preimage = payment_preimage; this.payment_hash = payment_hash; }
+                       public number fee_paid_msat;
+                       PaymentSent(Uint8Array payment_id, Uint8Array payment_preimage, Uint8Array payment_hash, number fee_paid_msat) { this.payment_id = payment_id; this.payment_preimage = payment_preimage; this.payment_hash = payment_hash; this.fee_paid_msat = fee_paid_msat; }
                }
                export class PaymentPathFailed extends LDKEvent {
+                       public Uint8Array payment_id;
                        public Uint8Array payment_hash;
                        public boolean rejected_by_dest;
                        public number network_update;
                        public boolean all_paths_failed;
                        public number[] path;
                        public number short_channel_id;
-                       PaymentPathFailed(Uint8Array payment_hash, boolean rejected_by_dest, number network_update, boolean all_paths_failed, number[] path, number short_channel_id) { 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; this.short_channel_id = short_channel_id; }
+                       public number retry;
+                       PaymentPathFailed(Uint8Array payment_id, Uint8Array payment_hash, boolean rejected_by_dest, number network_update, boolean all_paths_failed, number[] path, number short_channel_id, number retry) { this.payment_id = payment_id; 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; this.short_channel_id = short_channel_id; this.retry = retry; }
                }
                export class PendingHTLCsForwardable extends LDKEvent {
                        public number time_forwardable;
@@ -1375,7 +1417,6 @@ public static native long new_empty_slice_vec();
        static { LDKEvent.init(); }
        public static native LDKEvent LDKEvent_ref_from_ptr(long ptr);
        public static native long LDKCVec_EventZ_new(number[] elems);
-       public static native long LDKC2Tuple_u32TxOutZ_new(number a, number b);
        // uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple);
        export function C2Tuple_u32TxOutZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -1393,7 +1434,6 @@ public static native long new_empty_slice_vec();
                return nativeResponseValue;
        }
        public static native long LDKCVec_C2Tuple_u32TxOutZZ_new(number[] elems);
-       public static native long LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(Uint8Array a, number[] b);
        // struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple);
        export function C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -1443,7 +1483,6 @@ public static native long new_empty_slice_vec();
        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);
        // struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple);
        export function C2Tuple_PublicKeyTypeZ_get_a(tuple: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -1464,7 +1503,6 @@ public static native long new_empty_slice_vec();
        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);
-       public static native long LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(number a, number b, number c);
        // struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple);
        export function C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple: number): number {
                if(!isWasmInitialized) {
@@ -1572,12 +1610,6 @@ public static native long new_empty_slice_vec();
        }
        static { LDKCOption_CVec_NetAddressZZ.init(); }
        public static native LDKCOption_CVec_NetAddressZZ LDKCOption_CVec_NetAddressZZ_ref_from_ptr(long ptr);
-       public static native boolean LDKCResult_NetAddressu8Z_result_ok(long arg);
-       public static native number LDKCResult_NetAddressu8Z_get_ok(long arg);
-       public static native number LDKCResult_NetAddressu8Z_get_err(long arg);
-       public static native boolean LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(long arg);
-       public static native number LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(long arg);
-       public static native number LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(long arg);
        public static native boolean LDKCResult_NetAddressDecodeErrorZ_result_ok(long arg);
        public static native number LDKCResult_NetAddressDecodeErrorZ_get_ok(long arg);
        public static native number LDKCResult_NetAddressDecodeErrorZ_get_err(long arg);
@@ -1909,8 +1941,8 @@ public static native long new_empty_slice_vec();
 // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START
 
                export interface LDKPersist {
-                       persist_new_channel (id: number, data: number): number;
-                       update_persisted_channel (id: number, update: number, data: number): number;
+                       persist_new_channel (channel_id: number, data: number, update_id: number): number;
+                       update_persisted_channel (channel_id: number, update: number, data: number, update_id: number): number;
                }
 
                export function LDKPersist_new(impl: LDKPersist): number {
@@ -1920,20 +1952,20 @@ public static native long new_empty_slice_vec();
 // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END
 
 
-       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_persist_new_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data
-       export function Persist_persist_new_channel(this_arg: number, id: number, data: number): number {
+       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_persist_new_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id
+       export function Persist_persist_new_channel(this_arg: number, channel_id: number, data: number, update_id: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Persist_persist_new_channel(this_arg, id, data);
+               const nativeResponseValue = wasm.Persist_persist_new_channel(this_arg, channel_id, data, update_id);
                return nativeResponseValue;
        }
-       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_update_persisted_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data
-       export function Persist_update_persisted_channel(this_arg: number, id: number, update: number, data: number): number {
+       // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_update_persisted_channel LDKPersist *NONNULL_PTR this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id
+       export function Persist_update_persisted_channel(this_arg: number, channel_id: number, update: number, data: number, update_id: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Persist_update_persisted_channel(this_arg, id, update, data);
+               const nativeResponseValue = wasm.Persist_update_persisted_channel(this_arg, channel_id, update, data, update_id);
                return nativeResponseValue;
        }
 
@@ -2342,7 +2374,9 @@ public static native long new_empty_slice_vec();
 // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START
 
                export interface LDKScore {
-                       channel_penalty_msat (short_channel_id: number): number;
+                       channel_penalty_msat (short_channel_id: number, source: number, target: number): number;
+                       payment_path_failed (path: number[], short_channel_id: number): void;
+                       write (): Uint8Array;
                }
 
                export function LDKScore_new(impl: LDKScore): number {
@@ -2352,14 +2386,30 @@ public static native long new_empty_slice_vec();
 // OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END
 
 
-       // uint64_t Score_channel_penalty_msat LDKScore *NONNULL_PTR this_arg, uint64_t short_channel_id
-       export function Score_channel_penalty_msat(this_arg: number, short_channel_id: number): number {
+       // uint64_t Score_channel_penalty_msat LDKScore *NONNULL_PTR this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target
+       export function Score_channel_penalty_msat(this_arg: number, short_channel_id: number, source: number, target: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Score_channel_penalty_msat(this_arg, short_channel_id);
+               const nativeResponseValue = wasm.Score_channel_penalty_msat(this_arg, short_channel_id, source, target);
                return nativeResponseValue;
        }
+       // void Score_payment_path_failed LDKScore *NONNULL_PTR this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id
+       export function Score_payment_path_failed(this_arg: number, path: number[], short_channel_id: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Score_payment_path_failed(this_arg, path, short_channel_id);
+               // debug statements here
+       }
+       // LDKCVec_u8Z Score_write LDKScore *NONNULL_PTR this_arg
+       export function Score_write(this_arg: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Score_write(this_arg);
+               return decodeArray(nativeResponseValue);
+       }
 
 
 
@@ -2403,6 +2453,81 @@ public static native long new_empty_slice_vec();
        }
        static { LDKFallback.init(); }
        public static native LDKFallback LDKFallback_ref_from_ptr(long ptr);
+
+
+
+// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START
+
+               export interface LDKPayer {
+                       node_id (): Uint8Array;
+                       first_hops (): number[];
+                       send_payment (route: number, payment_hash: Uint8Array, payment_secret: Uint8Array): number;
+                       retry_payment (route: number, payment_id: Uint8Array): number;
+               }
+
+               export function LDKPayer_new(impl: LDKPayer): number {
+            throw new Error('unimplemented'); // TODO: bind to WASM
+        }
+
+// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END
+
+
+       // LDKPublicKey Payer_node_id LDKPayer *NONNULL_PTR this_arg
+       export function Payer_node_id(this_arg: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payer_node_id(this_arg);
+               return decodeArray(nativeResponseValue);
+       }
+       // LDKCVec_ChannelDetailsZ Payer_first_hops LDKPayer *NONNULL_PTR this_arg
+       export function Payer_first_hops(this_arg: number): number[] {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payer_first_hops(this_arg);
+               return nativeResponseValue;
+       }
+       // LDKCResult_PaymentIdPaymentSendFailureZ Payer_send_payment LDKPayer *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret
+       export function Payer_send_payment(this_arg: number, route: number, payment_hash: Uint8Array, payment_secret: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payer_send_payment(this_arg, route, encodeArray(payment_hash), encodeArray(payment_secret));
+               return nativeResponseValue;
+       }
+       // LDKCResult_NonePaymentSendFailureZ Payer_retry_payment LDKPayer *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id
+       export function Payer_retry_payment(this_arg: number, route: number, payment_id: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payer_retry_payment(this_arg, route, encodeArray(payment_id));
+               return nativeResponseValue;
+       }
+
+
+
+// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: START
+
+               export interface LDKRouter {
+                       find_route (payer: Uint8Array, params: number, first_hops: number[], scorer: number): number;
+               }
+
+               export function LDKRouter_new(impl: LDKRouter): number {
+            throw new Error('unimplemented'); // TODO: bind to WASM
+        }
+
+// OUT_TYPESCRIPT_BINDINGS :: MAP_TRAIT :: END
+
+
+       // LDKCResult_RouteLightningErrorZ Router_find_route LDKRouter *NONNULL_PTR this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer
+       export function Router_find_route(this_arg: number, payer: Uint8Array, params: number, first_hops: number[], scorer: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Router_find_route(this_arg, encodeArray(payer), params, first_hops, scorer);
+               return nativeResponseValue;
+       }
        // struct LDKStr _ldk_get_compiled_version(void);
        export function _ldk_get_compiled_version(): String {
                if(!isWasmInitialized) {
@@ -2979,6 +3104,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res);
                // debug statements here
        }
+       // struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig);
+       export function CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void);
        export function CResult_NoneErrorZ_ok(): number {
                if(!isWasmInitialized) {
@@ -3091,6 +3224,46 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_RouteDecodeErrorZ_clone(orig);
                return nativeResponseValue;
        }
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o);
+       export function CResult_RouteParametersDecodeErrorZ_ok(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteParametersDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_RouteParametersDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteParametersDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res);
+       export function CResult_RouteParametersDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteParametersDecodeErrorZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig);
+       export function CResult_RouteParametersDecodeErrorZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteParametersDecodeErrorZ_clone(orig);
+               return nativeResponseValue;
+       }
+       // void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res);
+       export function CVec_RouteHintZ_free(_res: number[]): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CVec_RouteHintZ_free(_res);
+               // debug statements here
+       }
        // struct LDKCOption_u64Z COption_u64Z_some(uint64_t o);
        export function COption_u64Z_some(o: number): number {
                if(!isWasmInitialized) {
@@ -3123,20 +3296,116 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.COption_u64Z_clone(orig);
                return nativeResponseValue;
        }
-       // void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res);
-       export function CVec_ChannelDetailsZ_free(_res: number[]): void {
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_ok(struct LDKPayee o);
+       export function CResult_PayeeDecodeErrorZ_ok(o: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CVec_ChannelDetailsZ_free(_res);
+               const nativeResponseValue = wasm.CResult_PayeeDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_PayeeDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PayeeDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_PayeeDecodeErrorZ_free(struct LDKCResult_PayeeDecodeErrorZ _res);
+       export function CResult_PayeeDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PayeeDecodeErrorZ_free(_res);
                // debug statements here
        }
-       // void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res);
-       export function CVec_RouteHintZ_free(_res: number[]): void {
+       // struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_clone(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR orig);
+       export function CResult_PayeeDecodeErrorZ_clone(orig: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CVec_RouteHintZ_free(_res);
+               const nativeResponseValue = wasm.CResult_PayeeDecodeErrorZ_clone(orig);
+               return nativeResponseValue;
+       }
+       // void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res);
+       export function CVec_RouteHintHopZ_free(_res: number[]): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CVec_RouteHintHopZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o);
+       export function CResult_RouteHintDecodeErrorZ_ok(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_RouteHintDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res);
+       export function CResult_RouteHintDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintDecodeErrorZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig);
+       export function CResult_RouteHintDecodeErrorZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintDecodeErrorZ_clone(orig);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o);
+       export function CResult_RouteHintHopDecodeErrorZ_ok(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintHopDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_RouteHintHopDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintHopDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res);
+       export function CResult_RouteHintHopDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintHopDecodeErrorZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig);
+       export function CResult_RouteHintHopDecodeErrorZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_RouteHintHopDecodeErrorZ_clone(orig);
+               return nativeResponseValue;
+       }
+       // void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res);
+       export function CVec_ChannelDetailsZ_free(_res: number[]): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CVec_ChannelDetailsZ_free(_res);
                // debug statements here
        }
        // struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o);
@@ -3459,6 +3728,54 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_InvoiceFeaturesDecodeErrorZ_free(_res);
                // debug statements here
        }
+       // struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o);
+       export function CResult_ScoringParametersDecodeErrorZ_ok(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScoringParametersDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_ScoringParametersDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScoringParametersDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res);
+       export function CResult_ScoringParametersDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScoringParametersDecodeErrorZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o);
+       export function CResult_ScorerDecodeErrorZ_ok(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScorerDecodeErrorZ_ok(o);
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_ScorerDecodeErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScorerDecodeErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res);
+       export function CResult_ScorerDecodeErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_ScorerDecodeErrorZ_free(_res);
+               // debug statements here
+       }
        // struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o);
        export function CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: number): number {
                if(!isWasmInitialized) {
@@ -3923,38 +4240,6 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig);
                return nativeResponseValue;
        }
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_ok(struct LDKPaymentId o);
-       export function CResult_PaymentIdDecodeErrorZ_ok(o: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_PaymentIdDecodeErrorZ_ok(o);
-               return nativeResponseValue;
-       }
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_err(struct LDKDecodeError e);
-       export function CResult_PaymentIdDecodeErrorZ_err(e: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_PaymentIdDecodeErrorZ_err(e);
-               return nativeResponseValue;
-       }
-       // void CResult_PaymentIdDecodeErrorZ_free(struct LDKCResult_PaymentIdDecodeErrorZ _res);
-       export function CResult_PaymentIdDecodeErrorZ_free(_res: number): void {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_PaymentIdDecodeErrorZ_free(_res);
-               // debug statements here
-       }
-       // struct LDKCResult_PaymentIdDecodeErrorZ CResult_PaymentIdDecodeErrorZ_clone(const struct LDKCResult_PaymentIdDecodeErrorZ *NONNULL_PTR orig);
-       export function CResult_PaymentIdDecodeErrorZ_clone(orig: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_PaymentIdDecodeErrorZ_clone(orig);
-               return nativeResponseValue;
-       }
        // struct LDKCOption_u16Z COption_u16Z_some(uint16_t o);
        export function COption_u16Z_some(o: number): number {
                if(!isWasmInitialized) {
@@ -4067,12 +4352,12 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult__u832APIErrorZ_clone(orig);
                return nativeResponseValue;
        }
-       // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKPaymentId o);
-       export function CResult_PaymentIdPaymentSendFailureZ_ok(o: number): number {
+       // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o);
+       export function CResult_PaymentIdPaymentSendFailureZ_ok(o: Uint8Array): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CResult_PaymentIdPaymentSendFailureZ_ok(o);
+               const nativeResponseValue = wasm.CResult_PaymentIdPaymentSendFailureZ_ok(encodeArray(o));
                return nativeResponseValue;
        }
        // struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e);
@@ -4139,12 +4424,12 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.C2Tuple_PaymentHashPaymentIdZ_clone(orig);
                return nativeResponseValue;
        }
-       // struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKPaymentId b);
-       export function C2Tuple_PaymentHashPaymentIdZ_new(a: Uint8Array, b: number): number {
+       // struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b);
+       export function C2Tuple_PaymentHashPaymentIdZ_new(a: Uint8Array, b: Uint8Array): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.C2Tuple_PaymentHashPaymentIdZ_new(encodeArray(a), b);
+               const nativeResponseValue = wasm.C2Tuple_PaymentHashPaymentIdZ_new(encodeArray(a), encodeArray(b));
                return nativeResponseValue;
        }
        // void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res);
@@ -4427,6 +4712,38 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.CResult_COption_TypeZDecodeErrorZ_clone(orig);
                return nativeResponseValue;
        }
+       // struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o);
+       export function CResult_PaymentIdPaymentErrorZ_ok(o: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PaymentIdPaymentErrorZ_ok(encodeArray(o));
+               return nativeResponseValue;
+       }
+       // struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e);
+       export function CResult_PaymentIdPaymentErrorZ_err(e: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PaymentIdPaymentErrorZ_err(e);
+               return nativeResponseValue;
+       }
+       // void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res);
+       export function CResult_PaymentIdPaymentErrorZ_free(_res: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PaymentIdPaymentErrorZ_free(_res);
+               // debug statements here
+       }
+       // struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig);
+       export function CResult_PaymentIdPaymentErrorZ_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.CResult_PaymentIdPaymentErrorZ_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o);
        export function CResult_SiPrefixNoneZ_ok(o: SiPrefix): number {
                if(!isWasmInitialized) {
@@ -5635,96 +5952,32 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.COption_CVec_NetAddressZZ_clone(orig);
                return nativeResponseValue;
        }
-       // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_ok(struct LDKNetAddress o);
-       export function CResult_NetAddressu8Z_ok(o: number): number {
+       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o);
+       export function CResult_NetAddressDecodeErrorZ_ok(o: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CResult_NetAddressu8Z_ok(o);
+               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_ok(o);
                return nativeResponseValue;
        }
-       // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_err(uint8_t e);
-       export function CResult_NetAddressu8Z_err(e: number): number {
+       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e);
+       export function CResult_NetAddressDecodeErrorZ_err(e: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CResult_NetAddressu8Z_err(e);
+               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_err(e);
                return nativeResponseValue;
        }
-       // void CResult_NetAddressu8Z_free(struct LDKCResult_NetAddressu8Z _res);
-       export function CResult_NetAddressu8Z_free(_res: number): void {
+       // void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res);
+       export function CResult_NetAddressDecodeErrorZ_free(_res: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.CResult_NetAddressu8Z_free(_res);
+               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_free(_res);
                // debug statements here
        }
-       // struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const struct LDKCResult_NetAddressu8Z *NONNULL_PTR orig);
-       export function CResult_NetAddressu8Z_clone(orig: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_NetAddressu8Z_clone(orig);
-               return nativeResponseValue;
-       }
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(struct LDKCResult_NetAddressu8Z o);
-       export function CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o);
-               return nativeResponseValue;
-       }
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_err(struct LDKDecodeError e);
-       export function CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e);
-               return nativeResponseValue;
-       }
-       // void CResult_CResult_NetAddressu8ZDecodeErrorZ_free(struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res);
-       export function CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res: number): void {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res);
-               // debug statements here
-       }
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(const struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *NONNULL_PTR orig);
-       export function CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig);
-               return nativeResponseValue;
-       }
-       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o);
-       export function CResult_NetAddressDecodeErrorZ_ok(o: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_ok(o);
-               return nativeResponseValue;
-       }
-       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e);
-       export function CResult_NetAddressDecodeErrorZ_err(e: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_err(e);
-               return nativeResponseValue;
-       }
-       // void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res);
-       export function CResult_NetAddressDecodeErrorZ_free(_res: number): void {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.CResult_NetAddressDecodeErrorZ_free(_res);
-               // debug statements here
-       }
-       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig);
-       export function CResult_NetAddressDecodeErrorZ_clone(orig: number): number {
+       // struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig);
+       export function CResult_NetAddressDecodeErrorZ_clone(orig: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
@@ -7019,20 +7272,20 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Event_payment_received(encodeArray(payment_hash), amt, purpose);
                return nativeResponseValue;
        }
-       // struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash);
-       export function Event_payment_sent(payment_preimage: Uint8Array, payment_hash: Uint8Array): number {
+       // struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat);
+       export function Event_payment_sent(payment_id: Uint8Array, payment_preimage: Uint8Array, payment_hash: Uint8Array, fee_paid_msat: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Event_payment_sent(encodeArray(payment_preimage), encodeArray(payment_hash));
+               const nativeResponseValue = wasm.Event_payment_sent(encodeArray(payment_id), encodeArray(payment_preimage), encodeArray(payment_hash), fee_paid_msat);
                return nativeResponseValue;
        }
-       // 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, struct LDKCOption_u64Z short_channel_id);
-       export function Event_payment_path_failed(payment_hash: Uint8Array, rejected_by_dest: boolean, network_update: number, all_paths_failed: boolean, path: number[], short_channel_id: number): number {
+       // struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry);
+       export function Event_payment_path_failed(payment_id: Uint8Array, payment_hash: Uint8Array, rejected_by_dest: boolean, network_update: number, all_paths_failed: boolean, path: number[], short_channel_id: number, retry: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Event_payment_path_failed(encodeArray(payment_hash), rejected_by_dest, network_update, all_paths_failed, path, short_channel_id);
+               const nativeResponseValue = wasm.Event_payment_path_failed(encodeArray(payment_id), encodeArray(payment_hash), rejected_by_dest, network_update, all_paths_failed, path, short_channel_id, retry);
                return nativeResponseValue;
        }
        // struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable);
@@ -8211,6 +8464,38 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.FeeEstimator_free(this_ptr);
                // debug statements here
        }
+       // void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj);
+       export function MonitorUpdateId_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateId_free(this_obj);
+               // debug statements here
+       }
+       // struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig);
+       export function MonitorUpdateId_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateId_clone(orig);
+               return nativeResponseValue;
+       }
+       // uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o);
+       export function MonitorUpdateId_hash(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateId_hash(o);
+               return nativeResponseValue;
+       }
+       // bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b);
+       export function MonitorUpdateId_eq(a: number, b: number): boolean {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateId_eq(a, b);
+               return nativeResponseValue;
+       }
        // void Persist_free(struct LDKPersist this_ptr);
        export function Persist_free(this_ptr: number): void {
                if(!isWasmInitialized) {
@@ -8267,6 +8552,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.ChainMonitor_list_monitors(this_arg);
                return nativeResponseValue;
        }
+       // MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, struct LDKMonitorUpdateId completed_update_id);
+       export function ChainMonitor_channel_monitor_updated(this_arg: number, funding_txo: number, completed_update_id: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ChainMonitor_channel_monitor_updated(this_arg, funding_txo, completed_update_id);
+               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) {
@@ -8355,6 +8648,30 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.MonitorUpdateError_free(this_obj);
                // debug statements here
        }
+       // struct LDKStr MonitorUpdateError_get_a(const struct LDKMonitorUpdateError *NONNULL_PTR this_ptr);
+       export function MonitorUpdateError_get_a(this_ptr: number): String {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateError_get_a(this_ptr);
+               return nativeResponseValue;
+       }
+       // void MonitorUpdateError_set_a(struct LDKMonitorUpdateError *NONNULL_PTR this_ptr, struct LDKStr val);
+       export function MonitorUpdateError_set_a(this_ptr: number, val: String): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateError_set_a(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKMonitorUpdateError MonitorUpdateError_new(struct LDKStr a_arg);
+       export function MonitorUpdateError_new(a_arg: String): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorUpdateError_new(a_arg);
+               return nativeResponseValue;
+       }
        // struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig);
        export function MonitorUpdateError_clone(orig: number): number {
                if(!isWasmInitialized) {
@@ -8395,6 +8712,30 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.MonitorEvent_commitment_tx_confirmed(a);
                return nativeResponseValue;
        }
+       // struct LDKMonitorEvent MonitorEvent_update_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id);
+       export function MonitorEvent_update_completed(funding_txo: number, monitor_update_id: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorEvent_update_completed(funding_txo, monitor_update_id);
+               return nativeResponseValue;
+       }
+       // struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a);
+       export function MonitorEvent_update_failed(a: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorEvent_update_failed(a);
+               return nativeResponseValue;
+       }
+       // struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj);
+       export function MonitorEvent_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MonitorEvent_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
        // void HTLCUpdate_free(struct LDKHTLCUpdate this_obj);
        export function HTLCUpdate_free(this_obj: number): void {
                if(!isWasmInitialized) {
@@ -9323,54 +9664,6 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.KeysManager_as_KeysInterface(this_arg);
                return nativeResponseValue;
        }
-       // void PaymentId_free(struct LDKPaymentId this_obj);
-       export function PaymentId_free(this_obj: number): void {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_free(this_obj);
-               // debug statements here
-       }
-       // uint64_t PaymentId_hash(const struct LDKPaymentId *NONNULL_PTR o);
-       export function PaymentId_hash(o: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_hash(o);
-               return nativeResponseValue;
-       }
-       // struct LDKPaymentId PaymentId_clone(const struct LDKPaymentId *NONNULL_PTR orig);
-       export function PaymentId_clone(orig: number): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_clone(orig);
-               return nativeResponseValue;
-       }
-       // bool PaymentId_eq(const struct LDKPaymentId *NONNULL_PTR a, const struct LDKPaymentId *NONNULL_PTR b);
-       export function PaymentId_eq(a: number, b: number): boolean {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_eq(a, b);
-               return nativeResponseValue;
-       }
-       // struct LDKCVec_u8Z PaymentId_write(const struct LDKPaymentId *NONNULL_PTR obj);
-       export function PaymentId_write(obj: number): Uint8Array {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_write(obj);
-               return decodeArray(nativeResponseValue);
-       }
-       // struct LDKCResult_PaymentIdDecodeErrorZ PaymentId_read(struct LDKu8slice ser);
-       export function PaymentId_read(ser: Uint8Array): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.PaymentId_read(encodeArray(ser));
-               return nativeResponseValue;
-       }
        // void ChannelManager_free(struct LDKChannelManager this_obj);
        export function ChannelManager_free(this_obj: number): void {
                if(!isWasmInitialized) {
@@ -9899,12 +10192,12 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.PaymentSendFailure_all_failed_retry_safe(a);
                return nativeResponseValue;
        }
-       // struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ a);
-       export function PaymentSendFailure_partial_failure(a: number[]): number {
+       // struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id);
+       export function PaymentSendFailure_partial_failure(results: number[], failed_paths_retry: number, payment_id: Uint8Array): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.PaymentSendFailure_partial_failure(a);
+               const nativeResponseValue = wasm.PaymentSendFailure_partial_failure(results, failed_paths_retry, encodeArray(payment_id));
                return nativeResponseValue;
        }
        // MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params);
@@ -9987,12 +10280,12 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.ChannelManager_send_payment(this_arg, route, encodeArray(payment_hash), encodeArray(payment_secret));
                return nativeResponseValue;
        }
-       // MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKPaymentId payment_id);
-       export function ChannelManager_retry_payment(this_arg: number, route: number, payment_id: number): number {
+       // MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id);
+       export function ChannelManager_retry_payment(this_arg: number, route: number, payment_id: Uint8Array): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.ChannelManager_retry_payment(this_arg, route, payment_id);
+               const nativeResponseValue = wasm.ChannelManager_retry_payment(this_arg, route, encodeArray(payment_id));
                return nativeResponseValue;
        }
        // MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage);
@@ -10059,14 +10352,6 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.ChannelManager_get_our_node_id(this_arg);
                return decodeArray(nativeResponseValue);
        }
-       // void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOutPoint *NONNULL_PTR funding_txo, uint64_t highest_applied_update_id);
-       export function ChannelManager_channel_monitor_updated(this_arg: number, funding_txo: number, highest_applied_update_id: number): void {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.ChannelManager_channel_monitor_updated(this_arg, funding_txo, highest_applied_update_id);
-               // debug statements here
-       }
        // MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id);
        export function ChannelManager_create_inbound_payment(this_arg: number, min_value_msat: number, invoice_expiry_delta_secs: number, user_payment_id: number): number {
                if(!isWasmInitialized) {
@@ -12163,14 +12448,6 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.NetAddress_write(obj);
                return decodeArray(nativeResponseValue);
        }
-       // struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser);
-       export function Result_read(ser: Uint8Array): number {
-               if(!isWasmInitialized) {
-                       throw new Error("initializeWasm() must be awaited first!");
-               }
-               const nativeResponseValue = wasm.Result_read(encodeArray(ser));
-               return nativeResponseValue;
-       }
        // struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser);
        export function NetAddress_read(ser: Uint8Array): number {
                if(!isWasmInitialized) {
@@ -14147,6 +14424,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.PeerManager_disconnect_by_node_id(this_arg, encodeArray(node_id), no_connection_possible);
                // debug statements here
        }
+       // void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg);
+       export function PeerManager_disconnect_all_peers(this_arg: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PeerManager_disconnect_all_peers(this_arg);
+               // debug statements here
+       }
        // void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
        export function PeerManager_timer_tick_occurred(this_arg: number): void {
                if(!isWasmInitialized) {
@@ -15035,6 +15320,22 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.ClosingTransaction_free(this_obj);
                // debug statements here
        }
+       // struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig);
+       export function ClosingTransaction_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ClosingTransaction_clone(orig);
+               return nativeResponseValue;
+       }
+       // uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o);
+       export function ClosingTransaction_hash(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ClosingTransaction_hash(o);
+               return nativeResponseValue;
+       }
        // 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) {
@@ -15579,6 +15880,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.InvalidShutdownScript_new(encodeArray(script_arg));
                return nativeResponseValue;
        }
+       // struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig);
+       export function InvalidShutdownScript_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvalidShutdownScript_clone(orig);
+               return nativeResponseValue;
+       }
        // struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj);
        export function ShutdownScript_write(obj: number): Uint8Array {
                if(!isWasmInitialized) {
@@ -15675,6 +15984,30 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Score_free(this_ptr);
                // debug statements here
        }
+       // void LockableScore_free(struct LDKLockableScore this_obj);
+       export function LockableScore_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.LockableScore_free(this_obj);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKLockableScore LockableScore_new(struct LDKScore score);
+       export function LockableScore_new(score: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.LockableScore_new(score);
+               return nativeResponseValue;
+       }
+       // struct LDKCVec_u8Z LockableScore_write(const struct LDKLockableScore *NONNULL_PTR obj);
+       export function LockableScore_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.LockableScore_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
        // void NodeId_free(struct LDKNodeId this_obj);
        export function NodeId_free(this_obj: number): void {
                if(!isWasmInitialized) {
@@ -15819,23 +16152,7 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.NetGraphMsgHandler_free(this_obj);
                // debug statements here
        }
-       // 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_get_network_graph(this_ptr);
-               return nativeResponseValue;
-       }
-       // 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);
+       // MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(const struct LDKNetworkGraph *NONNULL_PTR 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!");
@@ -16747,12 +17064,28 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Route_set_paths(this_ptr, val);
                // debug statements here
        }
-       // MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg);
-       export function Route_new(paths_arg: number[][]): number {
+       // struct LDKPayee Route_get_payee(const struct LDKRoute *NONNULL_PTR this_ptr);
+       export function Route_get_payee(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Route_get_payee(this_ptr);
+               return nativeResponseValue;
+       }
+       // void Route_set_payee(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPayee val);
+       export function Route_set_payee(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Route_set_payee(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKPayee payee_arg);
+       export function Route_new(paths_arg: number[][], payee_arg: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Route_new(paths_arg);
+               const nativeResponseValue = wasm.Route_new(paths_arg, payee_arg);
                return nativeResponseValue;
        }
        // struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig);
@@ -16811,116 +17144,380 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Route_read(encodeArray(ser));
                return nativeResponseValue;
        }
-       // void RouteHint_free(struct LDKRouteHint this_obj);
-       export function RouteHint_free(this_obj: number): void {
+       // void RouteParameters_free(struct LDKRouteParameters this_obj);
+       export function RouteParameters_free(this_obj: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHint_free(this_obj);
+               const nativeResponseValue = wasm.RouteParameters_free(this_obj);
                // debug statements here
        }
-       // struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig);
-       export function RouteHint_clone(orig: number): number {
+       // struct LDKPayee RouteParameters_get_payee(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       export function RouteParameters_get_payee(this_ptr: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHint_clone(orig);
+               const nativeResponseValue = wasm.RouteParameters_get_payee(this_ptr);
                return nativeResponseValue;
        }
-       // uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o);
-       export function RouteHint_hash(o: number): number {
+       // void RouteParameters_set_payee(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPayee val);
+       export function RouteParameters_set_payee(this_ptr: number, val: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHint_hash(o);
-               return nativeResponseValue;
+               const nativeResponseValue = wasm.RouteParameters_set_payee(this_ptr, val);
+               // 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 {
+       // uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       export function RouteParameters_get_final_value_msat(this_ptr: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHint_eq(a, b);
+               const nativeResponseValue = wasm.RouteParameters_get_final_value_msat(this_ptr);
                return nativeResponseValue;
        }
-       // void RouteHintHop_free(struct LDKRouteHintHop this_obj);
-       export function RouteHintHop_free(this_obj: number): void {
+       // void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val);
+       export function RouteParameters_set_final_value_msat(this_ptr: number, val: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_free(this_obj);
+               const nativeResponseValue = wasm.RouteParameters_set_final_value_msat(this_ptr, val);
                // debug statements here
        }
-       // struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
-       export function RouteHintHop_get_src_node_id(this_ptr: number): Uint8Array {
+       // uint32_t RouteParameters_get_final_cltv_expiry_delta(const struct LDKRouteParameters *NONNULL_PTR this_ptr);
+       export function RouteParameters_get_final_cltv_expiry_delta(this_ptr: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_get_src_node_id(this_ptr);
-               return decodeArray(nativeResponseValue);
+               const nativeResponseValue = wasm.RouteParameters_get_final_cltv_expiry_delta(this_ptr);
+               return nativeResponseValue;
        }
-       // void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val);
-       export function RouteHintHop_set_src_node_id(this_ptr: number, val: Uint8Array): void {
+       // void RouteParameters_set_final_cltv_expiry_delta(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint32_t val);
+       export function RouteParameters_set_final_cltv_expiry_delta(this_ptr: number, val: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_set_src_node_id(this_ptr, encodeArray(val));
+               const nativeResponseValue = wasm.RouteParameters_set_final_cltv_expiry_delta(this_ptr, val);
                // debug statements here
        }
-       // uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
-       export function RouteHintHop_get_short_channel_id(this_ptr: number): number {
+       // MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPayee payee_arg, uint64_t final_value_msat_arg, uint32_t final_cltv_expiry_delta_arg);
+       export function RouteParameters_new(payee_arg: number, final_value_msat_arg: number, final_cltv_expiry_delta_arg: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_get_short_channel_id(this_ptr);
+               const nativeResponseValue = wasm.RouteParameters_new(payee_arg, final_value_msat_arg, final_cltv_expiry_delta_arg);
                return nativeResponseValue;
        }
-       // void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val);
-       export function RouteHintHop_set_short_channel_id(this_ptr: number, val: number): void {
+       // struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig);
+       export function RouteParameters_clone(orig: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_set_short_channel_id(this_ptr, val);
-               // debug statements here
+               const nativeResponseValue = wasm.RouteParameters_clone(orig);
+               return nativeResponseValue;
        }
-       // struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
-       export function RouteHintHop_get_fees(this_ptr: number): number {
+       // struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj);
+       export function RouteParameters_write(obj: number): Uint8Array {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_get_fees(this_ptr);
+               const nativeResponseValue = wasm.RouteParameters_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser);
+       export function RouteParameters_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteParameters_read(encodeArray(ser));
                return nativeResponseValue;
        }
-       // void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val);
-       export function RouteHintHop_set_fees(this_ptr: number, val: number): void {
+       // void Payee_free(struct LDKPayee this_obj);
+       export function Payee_free(this_obj: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_set_fees(this_ptr, val);
+               const nativeResponseValue = wasm.Payee_free(this_obj);
                // debug statements here
        }
-       // uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
-       export function RouteHintHop_get_cltv_expiry_delta(this_ptr: number): number {
+       // struct LDKPublicKey Payee_get_pubkey(const struct LDKPayee *NONNULL_PTR this_ptr);
+       export function Payee_get_pubkey(this_ptr: number): Uint8Array {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_get_cltv_expiry_delta(this_ptr);
-               return nativeResponseValue;
+               const nativeResponseValue = wasm.Payee_get_pubkey(this_ptr);
+               return decodeArray(nativeResponseValue);
        }
-       // void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val);
-       export function RouteHintHop_set_cltv_expiry_delta(this_ptr: number, val: number): void {
+       // void Payee_set_pubkey(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+       export function Payee_set_pubkey(this_ptr: number, val: Uint8Array): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_set_cltv_expiry_delta(this_ptr, val);
+               const nativeResponseValue = wasm.Payee_set_pubkey(this_ptr, encodeArray(val));
                // debug statements here
        }
-       // struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
-       export function RouteHintHop_get_htlc_minimum_msat(this_ptr: number): number {
+       // struct LDKInvoiceFeatures Payee_get_features(const struct LDKPayee *NONNULL_PTR this_ptr);
+       export function Payee_get_features(this_ptr: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.RouteHintHop_get_htlc_minimum_msat(this_ptr);
+               const nativeResponseValue = wasm.Payee_get_features(this_ptr);
+               return nativeResponseValue;
+       }
+       // void Payee_set_features(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKInvoiceFeatures val);
+       export function Payee_set_features(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_set_features(this_ptr, val);
+               // debug statements here
+       }
+       // struct LDKCVec_RouteHintZ Payee_get_route_hints(const struct LDKPayee *NONNULL_PTR this_ptr);
+       export function Payee_get_route_hints(this_ptr: number): number[] {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_get_route_hints(this_ptr);
+               return nativeResponseValue;
+       }
+       // void Payee_set_route_hints(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintZ val);
+       export function Payee_set_route_hints(this_ptr: number, val: number[]): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_set_route_hints(this_ptr, val);
+               // debug statements here
+       }
+       // struct LDKCOption_u64Z Payee_get_expiry_time(const struct LDKPayee *NONNULL_PTR this_ptr);
+       export function Payee_get_expiry_time(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_get_expiry_time(this_ptr);
+               return nativeResponseValue;
+       }
+       // void Payee_set_expiry_time(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
+       export function Payee_set_expiry_time(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_set_expiry_time(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKPayee Payee_new(struct LDKPublicKey pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg);
+       export function Payee_new(pubkey_arg: Uint8Array, features_arg: number, route_hints_arg: number[], expiry_time_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_new(encodeArray(pubkey_arg), features_arg, route_hints_arg, expiry_time_arg);
+               return nativeResponseValue;
+       }
+       // struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig);
+       export function Payee_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_clone(orig);
+               return nativeResponseValue;
+       }
+       // uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o);
+       export function Payee_hash(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_hash(o);
+               return nativeResponseValue;
+       }
+       // bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b);
+       export function Payee_eq(a: number, b: number): boolean {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_eq(a, b);
+               return nativeResponseValue;
+       }
+       // struct LDKCVec_u8Z Payee_write(const struct LDKPayee *NONNULL_PTR obj);
+       export function Payee_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_PayeeDecodeErrorZ Payee_read(struct LDKu8slice ser);
+       export function Payee_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_read(encodeArray(ser));
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKPayee Payee_from_node_id(struct LDKPublicKey pubkey);
+       export function Payee_from_node_id(pubkey: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_from_node_id(encodeArray(pubkey));
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKPayee Payee_for_keysend(struct LDKPublicKey pubkey);
+       export function Payee_for_keysend(pubkey: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payee_for_keysend(encodeArray(pubkey));
+               return nativeResponseValue;
+       }
+       // void RouteHint_free(struct LDKRouteHint this_obj);
+       export function RouteHint_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_free(this_obj);
+               // debug statements here
+       }
+       // struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr);
+       export function RouteHint_get_a(this_ptr: number): number[] {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_get_a(this_ptr);
+               return nativeResponseValue;
+       }
+       // void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val);
+       export function RouteHint_set_a(this_ptr: number, val: number[]): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_set_a(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg);
+       export function RouteHint_new(a_arg: number[]): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_new(a_arg);
+               return nativeResponseValue;
+       }
+       // 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_clone(orig);
+               return nativeResponseValue;
+       }
+       // 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_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;
+       }
+       // struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj);
+       export function RouteHint_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser);
+       export function RouteHint_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHint_read(encodeArray(ser));
+               return nativeResponseValue;
+       }
+       // void RouteHintHop_free(struct LDKRouteHintHop this_obj);
+       export function RouteHintHop_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_free(this_obj);
+               // debug statements here
+       }
+       // struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
+       export function RouteHintHop_get_src_node_id(this_ptr: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_get_src_node_id(this_ptr);
+               return decodeArray(nativeResponseValue);
+       }
+       // void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+       export function RouteHintHop_set_src_node_id(this_ptr: number, val: Uint8Array): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_set_src_node_id(this_ptr, encodeArray(val));
+               // debug statements here
+       }
+       // uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
+       export function RouteHintHop_get_short_channel_id(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_get_short_channel_id(this_ptr);
+               return nativeResponseValue;
+       }
+       // void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val);
+       export function RouteHintHop_set_short_channel_id(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_set_short_channel_id(this_ptr, val);
+               // debug statements here
+       }
+       // struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
+       export function RouteHintHop_get_fees(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_get_fees(this_ptr);
+               return nativeResponseValue;
+       }
+       // void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val);
+       export function RouteHintHop_set_fees(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_set_fees(this_ptr, val);
+               // debug statements here
+       }
+       // uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
+       export function RouteHintHop_get_cltv_expiry_delta(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_get_cltv_expiry_delta(this_ptr);
+               return nativeResponseValue;
+       }
+       // void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val);
+       export function RouteHintHop_set_cltv_expiry_delta(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_set_cltv_expiry_delta(this_ptr, val);
+               // debug statements here
+       }
+       // struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr);
+       export function RouteHintHop_get_htlc_minimum_msat(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_get_htlc_minimum_msat(this_ptr);
                return nativeResponseValue;
        }
        // void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val);
@@ -16979,20 +17576,28 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.RouteHintHop_eq(a, b);
                return nativeResponseValue;
        }
-       // struct LDKCResult_RouteLightningErrorZ get_keysend_route(struct LDKPublicKey our_node_pubkey, 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, const struct LDKScore *NONNULL_PTR scorer);
-       export function get_keysend_route(our_node_pubkey: Uint8Array, network: number, payee: Uint8Array, first_hops: number[], last_hops: number[], final_value_msat: number, final_cltv: number, logger: number, scorer: number): number {
+       // struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj);
+       export function RouteHintHop_write(obj: number): Uint8Array {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.get_keysend_route(encodeArray(our_node_pubkey), network, encodeArray(payee), first_hops, last_hops, final_value_msat, final_cltv, logger, scorer);
+               const nativeResponseValue = wasm.RouteHintHop_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser);
+       export function RouteHintHop_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RouteHintHop_read(encodeArray(ser));
                return nativeResponseValue;
        }
-       // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_pubkey, 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, const struct LDKScore *NONNULL_PTR scorer);
-       export function get_route(our_node_pubkey: Uint8Array, network: number, payee: Uint8Array, payee_features: number, first_hops: number[], last_hops: number[], final_value_msat: number, final_cltv: number, logger: number, scorer: number): number {
+       // struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer);
+       export function find_route(our_node_pubkey: Uint8Array, params: number, network: number, first_hops: number[], logger: number, scorer: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.get_route(encodeArray(our_node_pubkey), network, encodeArray(payee), payee_features, first_hops, last_hops, final_value_msat, final_cltv, logger, scorer);
+               const nativeResponseValue = wasm.find_route(encodeArray(our_node_pubkey), params, network, first_hops, logger, scorer);
                return nativeResponseValue;
        }
        // void Scorer_free(struct LDKScorer this_obj);
@@ -17003,12 +17608,92 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Scorer_free(this_obj);
                // debug statements here
        }
-       // MUST_USE_RES struct LDKScorer Scorer_new(uint64_t base_penalty_msat);
-       export function Scorer_new(base_penalty_msat: number): number {
+       // void ScoringParameters_free(struct LDKScoringParameters this_obj);
+       export function ScoringParameters_free(this_obj: number): void {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Scorer_new(base_penalty_msat);
+               const nativeResponseValue = wasm.ScoringParameters_free(this_obj);
+               // debug statements here
+       }
+       // uint64_t ScoringParameters_get_base_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       export function ScoringParameters_get_base_penalty_msat(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_get_base_penalty_msat(this_ptr);
+               return nativeResponseValue;
+       }
+       // void ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       export function ScoringParameters_set_base_penalty_msat(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_set_base_penalty_msat(this_ptr, val);
+               // debug statements here
+       }
+       // uint64_t ScoringParameters_get_failure_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       export function ScoringParameters_get_failure_penalty_msat(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_get_failure_penalty_msat(this_ptr);
+               return nativeResponseValue;
+       }
+       // void ScoringParameters_set_failure_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       export function ScoringParameters_set_failure_penalty_msat(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_set_failure_penalty_msat(this_ptr, val);
+               // debug statements here
+       }
+       // uint64_t ScoringParameters_get_failure_penalty_half_life(const struct LDKScoringParameters *NONNULL_PTR this_ptr);
+       export function ScoringParameters_get_failure_penalty_half_life(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_get_failure_penalty_half_life(this_ptr);
+               return nativeResponseValue;
+       }
+       // void ScoringParameters_set_failure_penalty_half_life(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val);
+       export function ScoringParameters_set_failure_penalty_half_life(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_set_failure_penalty_half_life(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint64_t failure_penalty_half_life_arg);
+       export function ScoringParameters_new(base_penalty_msat_arg: number, failure_penalty_msat_arg: number, failure_penalty_half_life_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+               return nativeResponseValue;
+       }
+       // struct LDKCVec_u8Z ScoringParameters_write(const struct LDKScoringParameters *NONNULL_PTR obj);
+       export function ScoringParameters_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_ScoringParametersDecodeErrorZ ScoringParameters_read(struct LDKu8slice ser);
+       export function ScoringParameters_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_read(encodeArray(ser));
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKScorer Scorer_new(struct LDKScoringParameters params);
+       export function Scorer_new(params: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Scorer_new(params);
                return nativeResponseValue;
        }
        // MUST_USE_RES struct LDKScorer Scorer_default(void);
@@ -17019,6 +17704,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Scorer_default();
                return nativeResponseValue;
        }
+       // MUST_USE_RES struct LDKScoringParameters ScoringParameters_default(void);
+       export function ScoringParameters_default(): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ScoringParameters_default();
+               return nativeResponseValue;
+       }
        // struct LDKScore Scorer_as_Score(const struct LDKScorer *NONNULL_PTR this_arg);
        export function Scorer_as_Score(this_arg: number): number {
                if(!isWasmInitialized) {
@@ -17027,6 +17720,22 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Scorer_as_Score(this_arg);
                return nativeResponseValue;
        }
+       // struct LDKCVec_u8Z Scorer_write(const struct LDKScorer *NONNULL_PTR obj);
+       export function Scorer_write(obj: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Scorer_write(obj);
+               return decodeArray(nativeResponseValue);
+       }
+       // struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser);
+       export function Scorer_read(ser: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Scorer_read(encodeArray(ser));
+               return nativeResponseValue;
+       }
        // void FilesystemPersister_free(struct LDKFilesystemPersister this_obj);
        export function FilesystemPersister_free(this_obj: number): void {
                if(!isWasmInitialized) {
@@ -17467,6 +18176,30 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.PayeePubKey_free(this_obj);
                // debug statements here
        }
+       // struct LDKPublicKey PayeePubKey_get_a(const struct LDKPayeePubKey *NONNULL_PTR this_ptr);
+       export function PayeePubKey_get_a(this_ptr: number): Uint8Array {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PayeePubKey_get_a(this_ptr);
+               return decodeArray(nativeResponseValue);
+       }
+       // void PayeePubKey_set_a(struct LDKPayeePubKey *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+       export function PayeePubKey_set_a(this_ptr: number, val: Uint8Array): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PayeePubKey_set_a(this_ptr, encodeArray(val));
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKPayeePubKey PayeePubKey_new(struct LDKPublicKey a_arg);
+       export function PayeePubKey_new(a_arg: Uint8Array): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PayeePubKey_new(encodeArray(a_arg));
+               return nativeResponseValue;
+       }
        // struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig);
        export function PayeePubKey_clone(orig: number): number {
                if(!isWasmInitialized) {
@@ -17531,6 +18264,30 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.MinFinalCltvExpiry_free(this_obj);
                // debug statements here
        }
+       // uint64_t MinFinalCltvExpiry_get_a(const struct LDKMinFinalCltvExpiry *NONNULL_PTR this_ptr);
+       export function MinFinalCltvExpiry_get_a(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MinFinalCltvExpiry_get_a(this_ptr);
+               return nativeResponseValue;
+       }
+       // void MinFinalCltvExpiry_set_a(struct LDKMinFinalCltvExpiry *NONNULL_PTR this_ptr, uint64_t val);
+       export function MinFinalCltvExpiry_set_a(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MinFinalCltvExpiry_set_a(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_new(uint64_t a_arg);
+       export function MinFinalCltvExpiry_new(a_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.MinFinalCltvExpiry_new(a_arg);
+               return nativeResponseValue;
+       }
        // struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig);
        export function MinFinalCltvExpiry_clone(orig: number): number {
                if(!isWasmInitialized) {
@@ -17891,7 +18648,7 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Invoice_payee_pub_key(this_arg);
                return decodeArray(nativeResponseValue);
        }
-       // MUST_USE_RES struct LDKThirtyTwoBytes Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg);
+       // MUST_USE_RES const uint8_t (*Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg))[32];
        export function Invoice_payment_secret(this_arg: number): Uint8Array {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
@@ -17923,6 +18680,14 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Invoice_expiry_time(this_arg);
                return nativeResponseValue;
        }
+       // MUST_USE_RES bool Invoice_is_expired(const struct LDKInvoice *NONNULL_PTR this_arg);
+       export function Invoice_is_expired(this_arg: number): boolean {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Invoice_is_expired(this_arg);
+               return nativeResponseValue;
+       }
        // MUST_USE_RES uint64_t Invoice_min_final_cltv_expiry(const struct LDKInvoice *NONNULL_PTR this_arg);
        export function Invoice_min_final_cltv_expiry(this_arg: number): number {
                if(!isWasmInitialized) {
@@ -17955,12 +18720,12 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.Invoice_currency(this_arg);
                return nativeResponseValue;
        }
-       // MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_pico_btc(const struct LDKInvoice *NONNULL_PTR this_arg);
-       export function Invoice_amount_pico_btc(this_arg: number): number {
+       // MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_milli_satoshis(const struct LDKInvoice *NONNULL_PTR this_arg);
+       export function Invoice_amount_milli_satoshis(this_arg: number): number {
                if(!isWasmInitialized) {
                        throw new Error("initializeWasm() must be awaited first!");
                }
-               const nativeResponseValue = wasm.Invoice_amount_pico_btc(this_arg);
+               const nativeResponseValue = wasm.Invoice_amount_milli_satoshis(this_arg);
                return nativeResponseValue;
        }
        // MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKStr description);
@@ -18235,6 +19000,166 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.SignOrCreationError_to_str(o);
                return nativeResponseValue;
        }
+       // void InvoicePayer_free(struct LDKInvoicePayer this_obj);
+       export function InvoicePayer_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_free(this_obj);
+               // debug statements here
+       }
+       // void Payer_free(struct LDKPayer this_ptr);
+       export function Payer_free(this_ptr: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Payer_free(this_ptr);
+               // debug statements here
+       }
+       // void Router_free(struct LDKRouter this_ptr);
+       export function Router_free(this_ptr: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.Router_free(this_ptr);
+               // debug statements here
+       }
+       // void RetryAttempts_free(struct LDKRetryAttempts this_obj);
+       export function RetryAttempts_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_free(this_obj);
+               // debug statements here
+       }
+       // uintptr_t RetryAttempts_get_a(const struct LDKRetryAttempts *NONNULL_PTR this_ptr);
+       export function RetryAttempts_get_a(this_ptr: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_get_a(this_ptr);
+               return nativeResponseValue;
+       }
+       // void RetryAttempts_set_a(struct LDKRetryAttempts *NONNULL_PTR this_ptr, uintptr_t val);
+       export function RetryAttempts_set_a(this_ptr: number, val: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_set_a(this_ptr, val);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKRetryAttempts RetryAttempts_new(uintptr_t a_arg);
+       export function RetryAttempts_new(a_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_new(a_arg);
+               return nativeResponseValue;
+       }
+       // struct LDKRetryAttempts RetryAttempts_clone(const struct LDKRetryAttempts *NONNULL_PTR orig);
+       export function RetryAttempts_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_clone(orig);
+               return nativeResponseValue;
+       }
+       // bool RetryAttempts_eq(const struct LDKRetryAttempts *NONNULL_PTR a, const struct LDKRetryAttempts *NONNULL_PTR b);
+       export function RetryAttempts_eq(a: number, b: number): boolean {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_eq(a, b);
+               return nativeResponseValue;
+       }
+       // uint64_t RetryAttempts_hash(const struct LDKRetryAttempts *NONNULL_PTR o);
+       export function RetryAttempts_hash(o: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.RetryAttempts_hash(o);
+               return nativeResponseValue;
+       }
+       // void PaymentError_free(struct LDKPaymentError this_ptr);
+       export function PaymentError_free(this_ptr: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PaymentError_free(this_ptr);
+               // debug statements here
+       }
+       // struct LDKPaymentError PaymentError_clone(const struct LDKPaymentError *NONNULL_PTR orig);
+       export function PaymentError_clone(orig: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PaymentError_clone(orig);
+               return nativeResponseValue;
+       }
+       // struct LDKPaymentError PaymentError_invoice(struct LDKStr a);
+       export function PaymentError_invoice(a: String): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PaymentError_invoice(a);
+               return nativeResponseValue;
+       }
+       // struct LDKPaymentError PaymentError_routing(struct LDKLightningError a);
+       export function PaymentError_routing(a: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PaymentError_routing(a);
+               return nativeResponseValue;
+       }
+       // struct LDKPaymentError PaymentError_sending(struct LDKPaymentSendFailure a);
+       export function PaymentError_sending(a: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.PaymentError_sending(a);
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts);
+       export function InvoicePayer_new(payer: number, router: number, scorer: number, logger: number, event_handler: number, retry_attempts: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_new(payer, router, scorer, logger, event_handler, retry_attempts);
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice);
+       export function InvoicePayer_pay_invoice(this_arg: number, invoice: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_pay_invoice(this_arg, invoice);
+               return nativeResponseValue;
+       }
+       // MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_zero_value_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats);
+       export function InvoicePayer_pay_zero_value_invoice(this_arg: number, invoice: number, amount_msats: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_pay_zero_value_invoice(this_arg, invoice, amount_msats);
+               return nativeResponseValue;
+       }
+       // void InvoicePayer_remove_cached_payment(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]);
+       export function InvoicePayer_remove_cached_payment(this_arg: number, payment_hash: Uint8Array): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_remove_cached_payment(this_arg, encodeArray(payment_hash));
+               // debug statements here
+       }
+       // struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer *NONNULL_PTR this_arg);
+       export function InvoicePayer_as_EventHandler(this_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.InvoicePayer_as_EventHandler(this_arg);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description);
        export function create_invoice_from_channelmanager(channelmanager: number, keys_manager: number, network: Currency, amt_msat: number, description: String): number {
                if(!isWasmInitialized) {
@@ -18243,6 +19168,38 @@ public static native long new_empty_slice_vec();
                const nativeResponseValue = wasm.create_invoice_from_channelmanager(channelmanager, keys_manager, network, amt_msat, description);
                return nativeResponseValue;
        }
+       // void DefaultRouter_free(struct LDKDefaultRouter this_obj);
+       export function DefaultRouter_free(this_obj: number): void {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.DefaultRouter_free(this_obj);
+               // debug statements here
+       }
+       // MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger);
+       export function DefaultRouter_new(network_graph: number, logger: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.DefaultRouter_new(network_graph, logger);
+               return nativeResponseValue;
+       }
+       // struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg);
+       export function DefaultRouter_as_Router(this_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.DefaultRouter_as_Router(this_arg);
+               return nativeResponseValue;
+       }
+       // struct LDKPayer ChannelManager_as_Payer(const struct LDKChannelManager *NONNULL_PTR this_arg);
+       export function ChannelManager_as_Payer(this_arg: number): number {
+               if(!isWasmInitialized) {
+                       throw new Error("initializeWasm() must be awaited first!");
+               }
+               const nativeResponseValue = wasm.ChannelManager_as_Payer(this_arg);
+               return nativeResponseValue;
+       }
        // struct LDKCResult_SiPrefixNoneZ SiPrefix_from_str(struct LDKStr s);
        export function SiPrefix_from_str(s: String): number {
                if(!isWasmInitialized) {
index 902ef2685e41b0df738bc654ee415c9a27a2e4ee..356c5d4b78dd5dc13181c0b9538eb64c829a968f 100644 (file)
@@ -59,6 +59,12 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_conv_10_arr;
        }
 
+       public Result_NoneAPIErrorZ channel_monitor_updated(OutPoint funding_txo, MonitorUpdateId completed_update_id) {
+               number ret = bindings.ChainMonitor_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, completed_update_id == null ? 0 : completed_update_id.ptr & ~1);
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
        public Listen as_Listen() {
                number ret = bindings.ChainMonitor_as_Listen(this.ptr);
                Listen ret_hu_conv = new Listen(null, ret);
index 17136a1ef34029a5ff34bfb16d1af5753eb2710a..d9857373b719d9860dc8968990d1e1993030d32a 100644 (file)
@@ -96,8 +96,8 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_hu_conv;
        }
 
-       public Result_NonePaymentSendFailureZ retry_payment(Route route, PaymentId payment_id) {
-               number ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id == null ? 0 : payment_id.ptr & ~1);
+       public Result_NonePaymentSendFailureZ retry_payment(Route route, Uint8Array payment_id) {
+               number ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id);
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                this.ptrs_to.add(route);
                return ret_hu_conv;
@@ -143,11 +143,6 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
-       public void channel_monitor_updated(OutPoint funding_txo, number highest_applied_update_id) {
-               bindings.ChannelManager_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, highest_applied_update_id);
-               this.ptrs_to.add(funding_txo);
-       }
-
        public TwoTuple_PaymentHashPaymentSecretZ create_inbound_payment(Option_u64Z min_value_msat, number invoice_expiry_delta_secs, number user_payment_id) {
                number ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, user_payment_id);
                TwoTuple_PaymentHashPaymentSecretZ ret_hu_conv = new TwoTuple_PaymentHashPaymentSecretZ(null, ret);
@@ -217,4 +212,11 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
+       public Payer as_Payer() {
+               number ret = bindings.ChannelManager_as_Payer(this.ptr);
+               Payer ret_hu_conv = new Payer(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index f4b14a3e0c94c7e3eb3e01480c36bdd027c6be2f..7757ea9c525d8cecfa6421e5a4237e4e19c62dd9 100644 (file)
@@ -18,6 +18,18 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.ClosingTransaction_free(this.ptr);
                     }
                 }
+       public ClosingTransaction clone() {
+               number ret = bindings.ClosingTransaction_clone(this.ptr);
+               const ret_hu_conv: ClosingTransaction = new ClosingTransaction(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public number hash() {
+               number ret = bindings.ClosingTransaction_hash(this.ptr);
+               return ret;
+       }
+
        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);
diff --git a/ts/structs/DefaultRouter.ts b/ts/structs/DefaultRouter.ts
new file mode 100644 (file)
index 0000000..e4dee1e
--- /dev/null
@@ -0,0 +1,37 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class DefaultRouter extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.DefaultRouter_free(this.ptr);
+                    }
+                }
+       public static DefaultRouter constructor_new(NetworkGraph network_graph, Logger logger) {
+               number ret = bindings.DefaultRouter_new(network_graph == null ? 0 : network_graph.ptr & ~1, logger == null ? 0 : logger.ptr);
+               const ret_hu_conv: DefaultRouter = new DefaultRouter(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(network_graph);
+               ret_hu_conv.ptrs_to.add(logger);
+               return ret_hu_conv;
+       }
+
+       public Router as_Router() {
+               number ret = bindings.DefaultRouter_as_Router(this.ptr);
+               Router ret_hu_conv = new Router(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+}
index bd9ddd4d1a1da5957bc8765df1840f8741e18efa..36a548c89d7e5d287e7cdeb29202b92fa35c632e 100644 (file)
@@ -69,23 +69,33 @@ export class PaymentReceived extends Event {
        }
 }
 export class PaymentSent extends Event {
+       public payment_id: Uint8Array;
        public payment_preimage: Uint8Array;
        public payment_hash: Uint8Array;
+       public fee_paid_msat: Option_u64Z;
        private constructor(ptr: number, obj: bindings.LDKEvent.PaymentSent) {
                super(null, ptr);
+               this.payment_id = obj.payment_id;
                this.payment_preimage = obj.payment_preimage;
                this.payment_hash = obj.payment_hash;
+               const fee_paid_msat: number = obj.fee_paid_msat;
+               Option_u64Z fee_paid_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_paid_msat);
+                       fee_paid_msat_hu_conv.ptrs_to.add(this);
+               this.fee_paid_msat = fee_paid_msat_hu_conv;
        }
 }
 export class PaymentPathFailed extends Event {
+       public payment_id: Uint8Array;
        public payment_hash: Uint8Array;
        public rejected_by_dest: boolean;
        public network_update: Option_NetworkUpdateZ;
        public all_paths_failed: boolean;
        public path: RouteHop[];
        public short_channel_id: Option_u64Z;
+       public retry: RouteParameters;
        private constructor(ptr: number, obj: bindings.LDKEvent.PaymentPathFailed) {
                super(null, ptr);
+               this.payment_id = obj.payment_id;
                this.payment_hash = obj.payment_hash;
                this.rejected_by_dest = obj.rejected_by_dest;
                const network_update: number = obj.network_update;
@@ -106,6 +116,10 @@ export class PaymentPathFailed extends Event {
                Option_u64Z short_channel_id_hu_conv = Option_u64Z.constr_from_ptr(short_channel_id);
                        short_channel_id_hu_conv.ptrs_to.add(this);
                this.short_channel_id = short_channel_id_hu_conv;
+               const retry: number = obj.retry;
+               const retry_hu_conv: RouteParameters = new RouteParameters(null, retry);
+                       retry_hu_conv.ptrs_to.add(this);
+               this.retry = retry_hu_conv;
        }
 }
 export class PendingHTLCsForwardable extends Event {
@@ -186,15 +200,15 @@ export class DiscardFunding extends Event {
                return ret_hu_conv;
        }
 
-       public static Event constructor_payment_sent(Uint8Array payment_preimage, Uint8Array payment_hash) {
-               number ret = bindings.Event_payment_sent(payment_preimage, payment_hash);
+       public static Event constructor_payment_sent(Uint8Array payment_id, Uint8Array payment_preimage, Uint8Array payment_hash, Option_u64Z fee_paid_msat) {
+               number ret = bindings.Event_payment_sent(payment_id, payment_preimage, payment_hash, fee_paid_msat.ptr);
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
 
-       public static Event constructor_payment_path_failed(Uint8Array payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id) {
-               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, short_channel_id.ptr);
+       public static Event constructor_payment_path_failed(Uint8Array payment_id, Uint8Array payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id, RouteParameters retry) {
+               number ret = bindings.Event_payment_path_failed(payment_id, 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, short_channel_id.ptr, retry == null ? 0 : retry.ptr & ~1);
                Event ret_hu_conv = Event.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index ded8295c67d913cacdaf64bfc499fb5a0ca58901..57d7b9072a8c315325731299738f9c7771d68f4c 100644 (file)
@@ -34,4 +34,11 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_hu_conv;
        }
 
+       public InvalidShutdownScript clone() {
+               number ret = bindings.InvalidShutdownScript_clone(this.ptr);
+               const ret_hu_conv: InvalidShutdownScript = new InvalidShutdownScript(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index 5b9bfd41ff13569b0ffba2aa49fa1a2369448abe..d5fa849d28b9e38b1b2dad04eb87ba3ae6deb90c 100644 (file)
@@ -87,6 +87,11 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
+       public boolean is_expired() {
+               boolean ret = bindings.Invoice_is_expired(this.ptr);
+               return ret;
+       }
+
        public number min_final_cltv_expiry() {
                number ret = bindings.Invoice_min_final_cltv_expiry(this.ptr);
                return ret;
@@ -121,8 +126,8 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
-       public Option_u64Z amount_pico_btc() {
-               number ret = bindings.Invoice_amount_pico_btc(this.ptr);
+       public Option_u64Z amount_milli_satoshis() {
+               number ret = bindings.Invoice_amount_milli_satoshis(this.ptr);
                Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
diff --git a/ts/structs/InvoicePayer.ts b/ts/structs/InvoicePayer.ts
new file mode 100644 (file)
index 0000000..f76849f
--- /dev/null
@@ -0,0 +1,58 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class InvoicePayer extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.InvoicePayer_free(this.ptr);
+                    }
+                }
+       public static InvoicePayer constructor_new(Payer payer, Router router, LockableScore scorer, Logger logger, EventHandler event_handler, RetryAttempts retry_attempts) {
+               number ret = bindings.InvoicePayer_new(payer == null ? 0 : payer.ptr, router == null ? 0 : router.ptr, scorer == null ? 0 : scorer.ptr & ~1, logger == null ? 0 : logger.ptr, event_handler == null ? 0 : event_handler.ptr, retry_attempts == null ? 0 : retry_attempts.ptr & ~1);
+               const ret_hu_conv: InvoicePayer = new InvoicePayer(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(payer);
+               ret_hu_conv.ptrs_to.add(router);
+               ret_hu_conv.ptrs_to.add(scorer);
+               ret_hu_conv.ptrs_to.add(logger);
+               ret_hu_conv.ptrs_to.add(event_handler);
+               return ret_hu_conv;
+       }
+
+       public Result_PaymentIdPaymentErrorZ pay_invoice(Invoice invoice) {
+               number ret = bindings.InvoicePayer_pay_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1);
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(invoice);
+               return ret_hu_conv;
+       }
+
+       public Result_PaymentIdPaymentErrorZ pay_zero_value_invoice(Invoice invoice, number amount_msats) {
+               number ret = bindings.InvoicePayer_pay_zero_value_invoice(this.ptr, invoice == null ? 0 : invoice.ptr & ~1, amount_msats);
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(invoice);
+               return ret_hu_conv;
+       }
+
+       public void remove_cached_payment(Uint8Array payment_hash) {
+               bindings.InvoicePayer_remove_cached_payment(this.ptr, payment_hash);
+       }
+
+       public EventHandler as_EventHandler() {
+               number ret = bindings.InvoicePayer_as_EventHandler(this.ptr);
+               EventHandler ret_hu_conv = new EventHandler(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/LockableScore.ts b/ts/structs/LockableScore.ts
new file mode 100644 (file)
index 0000000..8eef837
--- /dev/null
@@ -0,0 +1,34 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class LockableScore extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.LockableScore_free(this.ptr);
+                    }
+                }
+       public static LockableScore constructor_new(Score score) {
+               number ret = bindings.LockableScore_new(score == null ? 0 : score.ptr);
+               const ret_hu_conv: LockableScore = new LockableScore(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(score);
+               return ret_hu_conv;
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.LockableScore_write(this.ptr);
+               return ret;
+       }
+
+}
index aab2cb4e6f842084bca46f31d8d94536163f92ca..28511146d6967f1a666271f6931eb3684d8af2d6 100644 (file)
@@ -18,6 +18,22 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.MinFinalCltvExpiry_free(this.ptr);
                     }
                 }
+       public number get_a() {
+               number ret = bindings.MinFinalCltvExpiry_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(number val) {
+               bindings.MinFinalCltvExpiry_set_a(this.ptr, val);
+       }
+
+       public static MinFinalCltvExpiry constructor_new(number a_arg) {
+               number ret = bindings.MinFinalCltvExpiry_new(a_arg);
+               const ret_hu_conv: MinFinalCltvExpiry = new MinFinalCltvExpiry(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        public MinFinalCltvExpiry clone() {
                number ret = bindings.MinFinalCltvExpiry_clone(this.ptr);
                const ret_hu_conv: MinFinalCltvExpiry = new MinFinalCltvExpiry(null, ret);
index 5fefa6b4f53a24f7c651ae23115ad5bce418cfe5..121b502547e2c3160a98474bea3baa5779da9d62 100644 (file)
@@ -16,6 +16,12 @@ export default class MonitorEvent extends CommonBase {
                if (raw_val instanceof bindings.LDKMonitorEvent.CommitmentTxConfirmed) {
                        return new CommitmentTxConfirmed(this.ptr, raw_val);
                }
+               if (raw_val instanceof bindings.LDKMonitorEvent.UpdateCompleted) {
+                       return new UpdateCompleted(this.ptr, raw_val);
+               }
+               if (raw_val instanceof bindings.LDKMonitorEvent.UpdateFailed) {
+                       return new UpdateFailed(this.ptr, raw_val);
+               }
                throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
        }
 
@@ -39,6 +45,28 @@ export class CommitmentTxConfirmed extends MonitorEvent {
                        commitment_tx_confirmed_hu_conv.ptrs_to.add(this);
                this.commitment_tx_confirmed = commitment_tx_confirmed_hu_conv;
        }
+}
+export class UpdateCompleted extends MonitorEvent {
+       public funding_txo: OutPoint;
+       public monitor_update_id: number;
+       private constructor(ptr: number, obj: bindings.LDKMonitorEvent.UpdateCompleted) {
+               super(null, ptr);
+               const funding_txo: number = obj.funding_txo;
+               const funding_txo_hu_conv: OutPoint = new OutPoint(null, funding_txo);
+                       funding_txo_hu_conv.ptrs_to.add(this);
+               this.funding_txo = funding_txo_hu_conv;
+               this.monitor_update_id = obj.monitor_update_id;
+       }
+}
+export class UpdateFailed extends MonitorEvent {
+       public update_failed: OutPoint;
+       private constructor(ptr: number, obj: bindings.LDKMonitorEvent.UpdateFailed) {
+               super(null, ptr);
+               const update_failed: number = obj.update_failed;
+               const update_failed_hu_conv: OutPoint = new OutPoint(null, update_failed);
+                       update_failed_hu_conv.ptrs_to.add(this);
+               this.update_failed = update_failed_hu_conv;
+       }
 }
        public MonitorEvent clone() {
                number ret = bindings.MonitorEvent_clone(this.ptr);
@@ -61,4 +89,23 @@ export class CommitmentTxConfirmed extends MonitorEvent {
                return ret_hu_conv;
        }
 
+       public static MonitorEvent constructor_update_completed(OutPoint funding_txo, number monitor_update_id) {
+               number ret = bindings.MonitorEvent_update_completed(funding_txo == null ? 0 : funding_txo.ptr & ~1, monitor_update_id);
+               MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public static MonitorEvent constructor_update_failed(OutPoint a) {
+               number ret = bindings.MonitorEvent_update_failed(a == null ? 0 : a.ptr & ~1);
+               MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.MonitorEvent_write(this.ptr);
+               return ret;
+       }
+
 }
index 1c457a8cf3ff35ae85c8526de010ec1a82a5080f..d76621adcee4037930de791347a9ce6e52979fce 100644 (file)
@@ -18,6 +18,22 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.MonitorUpdateError_free(this.ptr);
                     }
                 }
+       public String get_a() {
+               String ret = bindings.MonitorUpdateError_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(String val) {
+               bindings.MonitorUpdateError_set_a(this.ptr, val);
+       }
+
+       public static MonitorUpdateError constructor_new(String a_arg) {
+               number ret = bindings.MonitorUpdateError_new(a_arg);
+               const ret_hu_conv: MonitorUpdateError = new MonitorUpdateError(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        public MonitorUpdateError clone() {
                number ret = bindings.MonitorUpdateError_clone(this.ptr);
                const ret_hu_conv: MonitorUpdateError = new MonitorUpdateError(null, ret);
diff --git a/ts/structs/MonitorUpdateId.ts b/ts/structs/MonitorUpdateId.ts
new file mode 100644 (file)
index 0000000..9a792be
--- /dev/null
@@ -0,0 +1,39 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class MonitorUpdateId extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.MonitorUpdateId_free(this.ptr);
+                    }
+                }
+       public MonitorUpdateId clone() {
+               number ret = bindings.MonitorUpdateId_clone(this.ptr);
+               const ret_hu_conv: MonitorUpdateId = new MonitorUpdateId(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public number hash() {
+               number ret = bindings.MonitorUpdateId_hash(this.ptr);
+               return ret;
+       }
+
+       public boolean eq(MonitorUpdateId b) {
+               boolean ret = bindings.MonitorUpdateId_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+}
index e3726aa56f17ae0f80d9e0ee672fe8fee5ed1ec3..b4dbb87bed84b646eb13e70b1e40d22f958c6ef5 100644 (file)
@@ -25,21 +25,11 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_hu_conv;
        }
 
-       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 set_network_graph(NetworkGraph val) {
-               bindings.NetGraphMsgHandler_set_network_graph(this.ptr, val == null ? 0 : val.ptr & ~1);
-       }
-
        public static NetGraphMsgHandler constructor_new(NetworkGraph network_graph, Option_AccessZ chain_access, Logger logger) {
                number ret = bindings.NetGraphMsgHandler_new(network_graph == null ? 0 : network_graph.ptr & ~1, 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(network_graph);
                ret_hu_conv.ptrs_to.add(logger);
                return ret_hu_conv;
        }
diff --git a/ts/structs/Payee.ts b/ts/structs/Payee.ts
new file mode 100644 (file)
index 0000000..699bd71
--- /dev/null
@@ -0,0 +1,118 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class Payee extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.Payee_free(this.ptr);
+                    }
+                }
+       public Uint8Array get_pubkey() {
+               Uint8Array ret = bindings.Payee_get_pubkey(this.ptr);
+               return ret;
+       }
+
+       public void set_pubkey(Uint8Array val) {
+               bindings.Payee_set_pubkey(this.ptr, val);
+       }
+
+       public InvoiceFeatures get_features() {
+               number ret = bindings.Payee_get_features(this.ptr);
+               const ret_hu_conv: InvoiceFeatures = new InvoiceFeatures(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public void set_features(InvoiceFeatures val) {
+               bindings.Payee_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
+       public RouteHint[] get_route_hints() {
+               number[] ret = bindings.Payee_get_route_hints(this.ptr);
+               RouteHint[] ret_conv_11_arr = new RouteHint[ret.length];
+               for (int l = 0; l < ret.length; l++) {
+                       number ret_conv_11 = ret[l];
+                       const ret_conv_11_hu_conv: RouteHint = new RouteHint(null, ret_conv_11);
+                       ret_conv_11_hu_conv.ptrs_to.add(this);
+                       ret_conv_11_arr[l] = ret_conv_11_hu_conv;
+               }
+               return ret_conv_11_arr;
+       }
+
+       public void set_route_hints(RouteHint[] val) {
+               bindings.Payee_set_route_hints(this.ptr, val != null ? Arrays.stream(val).map(val_conv_11 -> val_conv_11 == null ? 0 : val_conv_11.ptr & ~1).toArray(number[]::new) : null);
+       }
+
+       public Option_u64Z get_expiry_time() {
+               number ret = bindings.Payee_get_expiry_time(this.ptr);
+               Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public void set_expiry_time(Option_u64Z val) {
+               bindings.Payee_set_expiry_time(this.ptr, val.ptr);
+       }
+
+       public static Payee constructor_new(Uint8Array pubkey_arg, InvoiceFeatures features_arg, RouteHint[] route_hints_arg, Option_u64Z expiry_time_arg) {
+               number ret = bindings.Payee_new(pubkey_arg, features_arg == null ? 0 : features_arg.ptr & ~1, route_hints_arg != null ? Arrays.stream(route_hints_arg).map(route_hints_arg_conv_11 -> route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr & ~1).toArray(number[]::new) : null, expiry_time_arg.ptr);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public Payee clone() {
+               number ret = bindings.Payee_clone(this.ptr);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public number hash() {
+               number ret = bindings.Payee_hash(this.ptr);
+               return ret;
+       }
+
+       public boolean eq(Payee b) {
+               boolean ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.Payee_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_PayeeDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.Payee_read(ser);
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Payee constructor_from_node_id(Uint8Array pubkey) {
+               number ret = bindings.Payee_from_node_id(pubkey);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public static Payee constructor_for_keysend(Uint8Array pubkey) {
+               number ret = bindings.Payee_for_keysend(pubkey);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+}
index 63b24e2d96cffc7188c2deae62e2e7bd3b809687..8e7373ee16d41e27b8fd16d143e6877b6b2c2d43 100644 (file)
@@ -18,6 +18,22 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.PayeePubKey_free(this.ptr);
                     }
                 }
+       public Uint8Array get_a() {
+               Uint8Array ret = bindings.PayeePubKey_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(Uint8Array val) {
+               bindings.PayeePubKey_set_a(this.ptr, val);
+       }
+
+       public static PayeePubKey constructor_new(Uint8Array a_arg) {
+               number ret = bindings.PayeePubKey_new(a_arg);
+               const ret_hu_conv: PayeePubKey = new PayeePubKey(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        public PayeePubKey clone() {
                number ret = bindings.PayeePubKey_clone(this.ptr);
                const ret_hu_conv: PayeePubKey = new PayeePubKey(null, ret);
diff --git a/ts/structs/Payer.ts b/ts/structs/Payer.ts
new file mode 100644 (file)
index 0000000..cd233a6
--- /dev/null
@@ -0,0 +1,108 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export class Payer extends CommonBase {
+
+                bindings_instance?: bindings.LDKPayer;
+
+                constructor(ptr?: number, arg?: bindings.LDKPayer) {
+                    if (Number.isFinite(ptr)) {
+                                       super(ptr);
+                                       this.bindings_instance = null;
+                                   } else {
+                                       // TODO: private constructor instantiation
+                                       super(bindings.LDKPayer_new(arg));
+                                       this.ptrs_to.push(arg);
+                                       
+                                   }
+                }
+
+                protected finalize() {
+                    if (this.ptr != 0) {
+                        bindings.Payer_free(this.ptr);
+                    }
+                    super.finalize();
+                }
+
+                static new_impl(arg: PayerInterface): Payer {
+                    const impl_holder: LDKPayerHolder = new LDKPayerHolder();
+                    let structImplementation = <bindings.LDKPayer>{
+                        // todo: in-line interface filling
+                        node_id (): Uint8Array {
+                                                       Uint8Array ret = arg.node_id();
+                               return ret;
+                                               },
+
+                                               first_hops (): number[] {
+                                                       ChannelDetails[] ret = arg.first_hops();
+                               result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_16 -> ret_conv_16 == null ? 0 : ret_conv_16.ptr & ~1).toArray(number[]::new) : null;
+                               return result;
+                                               },
+
+                                               send_payment (route: number, payment_hash: Uint8Array, payment_secret: Uint8Array): number {
+                                                       const route_hu_conv: Route = new Route(null, route);
+                                                       Result_PaymentIdPaymentSendFailureZ ret = arg.send_payment(route_hu_conv, payment_hash, payment_secret);
+                               result: number = ret != null ? ret.ptr : 0;
+                               return result;
+                                               },
+
+                                               retry_payment (route: number, payment_id: Uint8Array): number {
+                                                       const route_hu_conv: Route = new Route(null, route);
+                                                       Result_NonePaymentSendFailureZ ret = arg.retry_payment(route_hu_conv, payment_id);
+                               result: number = ret != null ? ret.ptr : 0;
+                               return result;
+                                               },
+
+                                               
+                    };
+                    impl_holder.held = new Payer (null, structImplementation);
+                }
+            }
+
+            export interface PayerInterface {
+                node_id(): Uint8Array;
+                               first_hops(): ChannelDetails[];
+                               send_payment(route: Route, payment_hash: Uint8Array, payment_secret: Uint8Array): Result_PaymentIdPaymentSendFailureZ;
+                               retry_payment(route: Route, payment_id: Uint8Array): Result_NonePaymentSendFailureZ;
+                               
+            }
+
+            class LDKPayerHolder {
+                held: Payer;
+            }
+       public Uint8Array node_id() {
+               Uint8Array ret = bindings.Payer_node_id(this.ptr);
+               return ret;
+       }
+
+       public ChannelDetails[] first_hops() {
+               number[] ret = bindings.Payer_first_hops(this.ptr);
+               ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
+               for (int q = 0; q < ret.length; q++) {
+                       number ret_conv_16 = ret[q];
+                       const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(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 Result_PaymentIdPaymentSendFailureZ send_payment(Route route, Uint8Array payment_hash, Uint8Array payment_secret) {
+               number ret = bindings.Payer_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_hash, payment_secret);
+               Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
+               this.ptrs_to.add(route);
+               return ret_hu_conv;
+       }
+
+       public Result_NonePaymentSendFailureZ retry_payment(Route route, Uint8Array payment_id) {
+               number ret = bindings.Payer_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_id);
+               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
+               this.ptrs_to.add(route);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/PaymentError.ts b/ts/structs/PaymentError.ts
new file mode 100644 (file)
index 0000000..da4a31f
--- /dev/null
@@ -0,0 +1,81 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+export default class PaymentError extends CommonBase {
+       protected constructor(_dummy: object, ptr: number) { super(ptr); }
+       protected finalize() {
+               super.finalize();
+               if (this.ptr != 0) { bindings.PaymentError_free(this.ptr); }
+       }
+       static constr_from_ptr(ptr: number): PaymentError {
+               const raw_val: bindings.LDKPaymentError = bindings.LDKPaymentError_ref_from_ptr(ptr);
+               if (raw_val instanceof bindings.LDKPaymentError.Invoice) {
+                       return new Invoice(this.ptr, raw_val);
+               }
+               if (raw_val instanceof bindings.LDKPaymentError.Routing) {
+                       return new Routing(this.ptr, raw_val);
+               }
+               if (raw_val instanceof bindings.LDKPaymentError.Sending) {
+                       return new Sending(this.ptr, raw_val);
+               }
+               throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
+       }
+
+}
+export class Invoice extends PaymentError {
+       public invoice: String;
+       private constructor(ptr: number, obj: bindings.LDKPaymentError.Invoice) {
+               super(null, ptr);
+               this.invoice = obj.invoice;
+       }
+}
+export class Routing extends PaymentError {
+       public routing: LightningError;
+       private constructor(ptr: number, obj: bindings.LDKPaymentError.Routing) {
+               super(null, ptr);
+               const routing: number = obj.routing;
+               const routing_hu_conv: LightningError = new LightningError(null, routing);
+                       routing_hu_conv.ptrs_to.add(this);
+               this.routing = routing_hu_conv;
+       }
+}
+export class Sending extends PaymentError {
+       public sending: PaymentSendFailure;
+       private constructor(ptr: number, obj: bindings.LDKPaymentError.Sending) {
+               super(null, ptr);
+               const sending: number = obj.sending;
+               PaymentSendFailure sending_hu_conv = PaymentSendFailure.constr_from_ptr(sending);
+                       sending_hu_conv.ptrs_to.add(this);
+               this.sending = sending_hu_conv;
+       }
+}
+       public PaymentError clone() {
+               number ret = bindings.PaymentError_clone(this.ptr);
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public static PaymentError constructor_invoice(String a) {
+               number ret = bindings.PaymentError_invoice(a);
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public static PaymentError constructor_routing(LightningError a) {
+               number ret = bindings.PaymentError_routing(a == null ? 0 : a.ptr & ~1);
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public static PaymentError constructor_sending(PaymentSendFailure a) {
+               number ret = bindings.PaymentError_sending(a.ptr);
+               PaymentError ret_hu_conv = PaymentError.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/PaymentId.ts b/ts/structs/PaymentId.ts
deleted file mode 100644 (file)
index 4657874..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-
-            
-import CommonBase from './CommonBase';
-import * as bindings from '../bindings' // TODO: figure out location
-
-
-
-            export default class PaymentId extends CommonBase {
-                constructor(_dummy: object, ptr: number) {
-                    super(ptr);
-                }
-
-                
-                protected finalize() {
-                    super.finalize();
-
-                    if (this.ptr != 0) {
-                        bindings.PaymentId_free(this.ptr);
-                    }
-                }
-       public number hash() {
-               number ret = bindings.PaymentId_hash(this.ptr);
-               return ret;
-       }
-
-       public PaymentId clone() {
-               number ret = bindings.PaymentId_clone(this.ptr);
-               const ret_hu_conv: PaymentId = new PaymentId(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
-       }
-
-       public boolean eq(PaymentId b) {
-               boolean ret = bindings.PaymentId_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
-               this.ptrs_to.add(b);
-               return ret;
-       }
-
-       public Uint8Array write() {
-               Uint8Array ret = bindings.PaymentId_write(this.ptr);
-               return ret;
-       }
-
-       public static Result_PaymentIdDecodeErrorZ constructor_read(Uint8Array ser) {
-               number ret = bindings.PaymentId_read(ser);
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
index 10fc46c6bc702a640384883733496a4e0e5e3b42..5aa12403631b8628599b7f1b0519ee6fe66643e8 100644 (file)
@@ -66,17 +66,24 @@ export class AllFailedRetrySafe extends PaymentSendFailure {
        }
 }
 export class PartialFailure extends PaymentSendFailure {
-       public partial_failure: Result_NoneAPIErrorZ[];
+       public results: Result_NoneAPIErrorZ[];
+       public failed_paths_retry: RouteParameters;
+       public payment_id: Uint8Array;
        private constructor(ptr: number, obj: bindings.LDKPaymentSendFailure.PartialFailure) {
                super(null, ptr);
-               const partial_failure: number[] = obj.partial_failure;
-               Result_NoneAPIErrorZ[] partial_failure_conv_22_arr = new Result_NoneAPIErrorZ[partial_failure.length];
-                       for (int w = 0; w < partial_failure.length; w++) {
-                               number partial_failure_conv_22 = partial_failure[w];
-                               Result_NoneAPIErrorZ partial_failure_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(partial_failure_conv_22);
-                               partial_failure_conv_22_arr[w] = partial_failure_conv_22_hu_conv;
+               const results: number[] = obj.results;
+               Result_NoneAPIErrorZ[] results_conv_22_arr = new Result_NoneAPIErrorZ[results.length];
+                       for (int w = 0; w < results.length; w++) {
+                               number results_conv_22 = results[w];
+                               Result_NoneAPIErrorZ results_conv_22_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(results_conv_22);
+                               results_conv_22_arr[w] = results_conv_22_hu_conv;
                        }
-               this.partial_failure = partial_failure_conv_22_arr;
+               this.results = results_conv_22_arr;
+               const failed_paths_retry: number = obj.failed_paths_retry;
+               const failed_paths_retry_hu_conv: RouteParameters = new RouteParameters(null, failed_paths_retry);
+                       failed_paths_retry_hu_conv.ptrs_to.add(this);
+               this.failed_paths_retry = failed_paths_retry_hu_conv;
+               this.payment_id = obj.payment_id;
        }
 }
        public PaymentSendFailure clone() {
@@ -107,8 +114,8 @@ export class PartialFailure extends PaymentSendFailure {
                return ret_hu_conv;
        }
 
-       public static PaymentSendFailure constructor_partial_failure(Result_NoneAPIErrorZ[] a) {
-               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);
+       public static PaymentSendFailure constructor_partial_failure(Result_NoneAPIErrorZ[] results, RouteParameters failed_paths_retry, Uint8Array payment_id) {
+               number ret = bindings.PaymentSendFailure_partial_failure(results != null ? Arrays.stream(results).map(results_conv_22 -> results_conv_22 != null ? results_conv_22.ptr : 0).toArray(number[]::new) : null, failed_paths_retry == null ? 0 : failed_paths_retry.ptr & ~1, payment_id);
                PaymentSendFailure ret_hu_conv = PaymentSendFailure.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index 3d3951de902aa27d2fb855b11cff443f2ff50e12..1b62d075b1054a823956989cb82020e80b9c4f8c 100644 (file)
@@ -72,6 +72,10 @@ import * as bindings from '../bindings' // TODO: figure out location
                bindings.PeerManager_disconnect_by_node_id(this.ptr, node_id, no_connection_possible);
        }
 
+       public void disconnect_all_peers() {
+               bindings.PeerManager_disconnect_all_peers(this.ptr);
+       }
+
        public void timer_tick_occurred() {
                bindings.PeerManager_timer_tick_occurred(this.ptr);
        }
index 68a951020670c2347ebea54ecd61784c4e18426e..f13f9b90c4329ced144002a83890f8d30ae5df36 100644 (file)
@@ -32,21 +32,25 @@ import * as bindings from '../bindings' // TODO: figure out location
                     const impl_holder: LDKPersistHolder = new LDKPersistHolder();
                     let structImplementation = <bindings.LDKPersist>{
                         // todo: in-line interface filling
-                        persist_new_channel (id: number, data: number): number {
-                                                       const id_hu_conv: OutPoint = new OutPoint(null, id);
-                               id_hu_conv.ptrs_to.add(this);
+                        persist_new_channel (channel_id: number, data: number, update_id: number): number {
+                                                       const channel_id_hu_conv: OutPoint = new OutPoint(null, channel_id);
+                               channel_id_hu_conv.ptrs_to.add(this);
                                                        const data_hu_conv: ChannelMonitor = new ChannelMonitor(null, data);
-                                                       Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv);
+                                                       const update_id_hu_conv: MonitorUpdateId = new MonitorUpdateId(null, update_id);
+                               update_id_hu_conv.ptrs_to.add(this);
+                                                       Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(channel_id_hu_conv, data_hu_conv, update_id_hu_conv);
                                result: number = ret != null ? ret.ptr : 0;
                                return result;
                                                },
 
-                                               update_persisted_channel (id: number, update: number, data: number): number {
-                                                       const id_hu_conv: OutPoint = new OutPoint(null, id);
-                               id_hu_conv.ptrs_to.add(this);
+                                               update_persisted_channel (channel_id: number, update: number, data: number, update_id: number): number {
+                                                       const channel_id_hu_conv: OutPoint = new OutPoint(null, channel_id);
+                               channel_id_hu_conv.ptrs_to.add(this);
                                                        const update_hu_conv: ChannelMonitorUpdate = new ChannelMonitorUpdate(null, update);
                                                        const data_hu_conv: ChannelMonitor = new ChannelMonitor(null, data);
-                                                       Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv);
+                                                       const update_id_hu_conv: MonitorUpdateId = new MonitorUpdateId(null, update_id);
+                               update_id_hu_conv.ptrs_to.add(this);
+                                                       Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(channel_id_hu_conv, update_hu_conv, data_hu_conv, update_id_hu_conv);
                                result: number = ret != null ? ret.ptr : 0;
                                return result;
                                                },
@@ -58,23 +62,23 @@ import * as bindings from '../bindings' // TODO: figure out location
             }
 
             export interface PersistInterface {
-                persist_new_channel(id: OutPoint, data: ChannelMonitor): Result_NoneChannelMonitorUpdateErrZ;
-                               update_persisted_channel(id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor): Result_NoneChannelMonitorUpdateErrZ;
+                persist_new_channel(channel_id: OutPoint, data: ChannelMonitor, update_id: MonitorUpdateId): Result_NoneChannelMonitorUpdateErrZ;
+                               update_persisted_channel(channel_id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor, update_id: MonitorUpdateId): Result_NoneChannelMonitorUpdateErrZ;
                                
             }
 
             class LDKPersistHolder {
                 held: Persist;
             }
-       public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) {
-               number ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1);
+       public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint channel_id, ChannelMonitor data, MonitorUpdateId update_id) {
+               number ret = bindings.Persist_persist_new_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1);
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(data);
                return ret_hu_conv;
        }
 
-       public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) {
-               number ret = bindings.Persist_update_persisted_channel(this.ptr, id == null ? 0 : id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1);
+       public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint channel_id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) {
+               number ret = bindings.Persist_update_persisted_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1);
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(update);
                this.ptrs_to.add(data);
diff --git a/ts/structs/Result_CResult_NetAddressu8ZDecodeErrorZ.ts b/ts/structs/Result_CResult_NetAddressu8ZDecodeErrorZ.ts
deleted file mode 100644 (file)
index a194458..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-import CommonBase from './CommonBase';
-import * as bindings from '../bindings' // TODO: figure out location
-
-public class Result_CResult_NetAddressu8ZDecodeErrorZ extends CommonBase {
-       private Result_CResult_NetAddressu8ZDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_free(ptr); } super.finalize();
-       }
-
-       static Result_CResult_NetAddressu8ZDecodeErrorZ constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(ptr)) {
-                       return new Result_CResult_NetAddressu8ZDecodeErrorZ_OK(null, ptr);
-               } else {
-                       return new Result_CResult_NetAddressu8ZDecodeErrorZ_Err(null, ptr);
-               }
-       }
-       public static final class Result_CResult_NetAddressu8ZDecodeErrorZ_OK extends Result_CResult_NetAddressu8ZDecodeErrorZ {
-               public final Result_NetAddressu8Z res;
-               private Result_CResult_NetAddressu8ZDecodeErrorZ_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       number res = bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(ptr);
-                       Result_NetAddressu8Z res_hu_conv = Result_NetAddressu8Z.constr_from_ptr(res);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_CResult_NetAddressu8ZDecodeErrorZ_Err extends Result_CResult_NetAddressu8ZDecodeErrorZ {
-               public final DecodeError err;
-               private Result_CResult_NetAddressu8ZDecodeErrorZ_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       number err = bindings.LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_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_CResult_NetAddressu8ZDecodeErrorZ constructor_ok(Result_NetAddressu8Z o) {
-               number ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o != null ? o.ptr : 0);
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public static Result_CResult_NetAddressu8ZDecodeErrorZ constructor_err(DecodeError e) {
-               number ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public Result_CResult_NetAddressu8ZDecodeErrorZ clone() {
-               number ret = bindings.CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(this.ptr);
-               Result_CResult_NetAddressu8ZDecodeErrorZ ret_hu_conv = Result_CResult_NetAddressu8ZDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
diff --git a/ts/structs/Result_NetAddressu8Z.ts b/ts/structs/Result_NetAddressu8Z.ts
deleted file mode 100644 (file)
index 54ae935..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-
-import CommonBase from './CommonBase';
-import * as bindings from '../bindings' // TODO: figure out location
-
-public class Result_NetAddressu8Z extends CommonBase {
-       private Result_NetAddressu8Z(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_NetAddressu8Z_free(ptr); } super.finalize();
-       }
-
-       static Result_NetAddressu8Z constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_NetAddressu8Z_result_ok(ptr)) {
-                       return new Result_NetAddressu8Z_OK(null, ptr);
-               } else {
-                       return new Result_NetAddressu8Z_Err(null, ptr);
-               }
-       }
-       public static final class Result_NetAddressu8Z_OK extends Result_NetAddressu8Z {
-               public final NetAddress res;
-               private Result_NetAddressu8Z_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       number res = bindings.LDKCResult_NetAddressu8Z_get_ok(ptr);
-                       NetAddress res_hu_conv = NetAddress.constr_from_ptr(res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_NetAddressu8Z_Err extends Result_NetAddressu8Z {
-               public final number err;
-               private Result_NetAddressu8Z_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       this.err = bindings.LDKCResult_NetAddressu8Z_get_err(ptr);
-               }
-       }
-
-       public static Result_NetAddressu8Z constructor_ok(NetAddress o) {
-               number ret = bindings.CResult_NetAddressu8Z_ok(o.ptr);
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public static Result_NetAddressu8Z constructor_err(number e) {
-               number ret = bindings.CResult_NetAddressu8Z_err(e);
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public Result_NetAddressu8Z clone() {
-               number ret = bindings.CResult_NetAddressu8Z_clone(this.ptr);
-               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
diff --git a/ts/structs/Result_PayeeDecodeErrorZ.ts b/ts/structs/Result_PayeeDecodeErrorZ.ts
new file mode 100644 (file)
index 0000000..1eed1cc
--- /dev/null
@@ -0,0 +1,58 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+public class Result_PayeeDecodeErrorZ extends CommonBase {
+       private Result_PayeeDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_PayeeDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_PayeeDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_PayeeDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_PayeeDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_PayeeDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_PayeeDecodeErrorZ_OK extends Result_PayeeDecodeErrorZ {
+               public final Payee res;
+               private Result_PayeeDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number res = bindings.LDKCResult_PayeeDecodeErrorZ_get_ok(ptr);
+                       const res_hu_conv: Payee = new Payee(null, res);
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_PayeeDecodeErrorZ_Err extends Result_PayeeDecodeErrorZ {
+               public final DecodeError err;
+               private Result_PayeeDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number err = bindings.LDKCResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ constructor_ok(Payee o) {
+               number ret = bindings.CResult_PayeeDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Result_PayeeDecodeErrorZ constructor_err(DecodeError e) {
+               number ret = bindings.CResult_PayeeDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_PayeeDecodeErrorZ clone() {
+               number ret = bindings.CResult_PayeeDecodeErrorZ_clone(this.ptr);
+               Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/Result_PaymentIdDecodeErrorZ.ts b/ts/structs/Result_PaymentIdDecodeErrorZ.ts
deleted file mode 100644 (file)
index 2c4fa27..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-
-import CommonBase from './CommonBase';
-import * as bindings from '../bindings' // TODO: figure out location
-
-public class Result_PaymentIdDecodeErrorZ extends CommonBase {
-       private Result_PaymentIdDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.CResult_PaymentIdDecodeErrorZ_free(ptr); } super.finalize();
-       }
-
-       static Result_PaymentIdDecodeErrorZ constr_from_ptr(long ptr) {
-               if (bindings.LDKCResult_PaymentIdDecodeErrorZ_result_ok(ptr)) {
-                       return new Result_PaymentIdDecodeErrorZ_OK(null, ptr);
-               } else {
-                       return new Result_PaymentIdDecodeErrorZ_Err(null, ptr);
-               }
-       }
-       public static final class Result_PaymentIdDecodeErrorZ_OK extends Result_PaymentIdDecodeErrorZ {
-               public final PaymentId res;
-               private Result_PaymentIdDecodeErrorZ_OK(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       number res = bindings.LDKCResult_PaymentIdDecodeErrorZ_get_ok(ptr);
-                       const res_hu_conv: PaymentId = new PaymentId(null, res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
-               }
-       }
-
-       public static final class Result_PaymentIdDecodeErrorZ_Err extends Result_PaymentIdDecodeErrorZ {
-               public final DecodeError err;
-               private Result_PaymentIdDecodeErrorZ_Err(Object _dummy, long ptr) {
-                       super(_dummy, ptr);
-                       number err = bindings.LDKCResult_PaymentIdDecodeErrorZ_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_PaymentIdDecodeErrorZ constructor_ok(PaymentId o) {
-               number ret = bindings.CResult_PaymentIdDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public static Result_PaymentIdDecodeErrorZ constructor_err(DecodeError e) {
-               number ret = bindings.CResult_PaymentIdDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       public Result_PaymentIdDecodeErrorZ clone() {
-               number ret = bindings.CResult_PaymentIdDecodeErrorZ_clone(this.ptr);
-               Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-}
diff --git a/ts/structs/Result_PaymentIdPaymentErrorZ.ts b/ts/structs/Result_PaymentIdPaymentErrorZ.ts
new file mode 100644 (file)
index 0000000..7b9eeb2
--- /dev/null
@@ -0,0 +1,55 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+public class Result_PaymentIdPaymentErrorZ extends CommonBase {
+       private Result_PaymentIdPaymentErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_PaymentIdPaymentErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_PaymentIdPaymentErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_PaymentIdPaymentErrorZ_result_ok(ptr)) {
+                       return new Result_PaymentIdPaymentErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_PaymentIdPaymentErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_PaymentIdPaymentErrorZ_OK extends Result_PaymentIdPaymentErrorZ {
+               public final Uint8Array res;
+               private Result_PaymentIdPaymentErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       this.res = bindings.LDKCResult_PaymentIdPaymentErrorZ_get_ok(ptr);
+               }
+       }
+
+       public static final class Result_PaymentIdPaymentErrorZ_Err extends Result_PaymentIdPaymentErrorZ {
+               public final PaymentError err;
+               private Result_PaymentIdPaymentErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number err = bindings.LDKCResult_PaymentIdPaymentErrorZ_get_err(ptr);
+                       PaymentError err_hu_conv = PaymentError.constr_from_ptr(err);
+                       err_hu_conv.ptrs_to.add(this);
+                       this.err = err_hu_conv;
+               }
+       }
+
+       public static Result_PaymentIdPaymentErrorZ constructor_ok(Uint8Array o) {
+               number ret = bindings.CResult_PaymentIdPaymentErrorZ_ok(o);
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Result_PaymentIdPaymentErrorZ constructor_err(PaymentError e) {
+               number ret = bindings.CResult_PaymentIdPaymentErrorZ_err(e.ptr);
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_PaymentIdPaymentErrorZ clone() {
+               number ret = bindings.CResult_PaymentIdPaymentErrorZ_clone(this.ptr);
+               Result_PaymentIdPaymentErrorZ ret_hu_conv = Result_PaymentIdPaymentErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index b8dd9ebfe35e77cd88302df684c78025b46af81d..f55ee0598247859ebf7760d4e4d0cd2d5b04b9a8 100644 (file)
@@ -16,13 +16,10 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
                }
        }
        public static final class Result_PaymentIdPaymentSendFailureZ_OK extends Result_PaymentIdPaymentSendFailureZ {
-               public final PaymentId res;
+               public final Uint8Array res;
                private Result_PaymentIdPaymentSendFailureZ_OK(Object _dummy, long ptr) {
                        super(_dummy, ptr);
-                       number res = bindings.LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(ptr);
-                       const res_hu_conv: PaymentId = new PaymentId(null, res);
-                       res_hu_conv.ptrs_to.add(this);
-                       this.res = res_hu_conv;
+                       this.res = bindings.LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(ptr);
                }
        }
 
@@ -37,8 +34,8 @@ public class Result_PaymentIdPaymentSendFailureZ extends CommonBase {
                }
        }
 
-       public static Result_PaymentIdPaymentSendFailureZ constructor_ok(PaymentId o) {
-               number ret = bindings.CResult_PaymentIdPaymentSendFailureZ_ok(o == null ? 0 : o.ptr & ~1);
+       public static Result_PaymentIdPaymentSendFailureZ constructor_ok(Uint8Array o) {
+               number ret = bindings.CResult_PaymentIdPaymentSendFailureZ_ok(o);
                Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/ts/structs/Result_RouteHintDecodeErrorZ.ts b/ts/structs/Result_RouteHintDecodeErrorZ.ts
new file mode 100644 (file)
index 0000000..1496e3c
--- /dev/null
@@ -0,0 +1,58 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+public class Result_RouteHintDecodeErrorZ extends CommonBase {
+       private Result_RouteHintDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteHintDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteHintDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteHintDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteHintDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteHintDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteHintDecodeErrorZ_OK extends Result_RouteHintDecodeErrorZ {
+               public final RouteHint res;
+               private Result_RouteHintDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number res = bindings.LDKCResult_RouteHintDecodeErrorZ_get_ok(ptr);
+                       const res_hu_conv: RouteHint = new RouteHint(null, res);
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteHintDecodeErrorZ_Err extends Result_RouteHintDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteHintDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number err = bindings.LDKCResult_RouteHintDecodeErrorZ_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_RouteHintDecodeErrorZ constructor_ok(RouteHint o) {
+               number ret = bindings.CResult_RouteHintDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Result_RouteHintDecodeErrorZ constructor_err(DecodeError e) {
+               number ret = bindings.CResult_RouteHintDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_RouteHintDecodeErrorZ clone() {
+               number ret = bindings.CResult_RouteHintDecodeErrorZ_clone(this.ptr);
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/Result_RouteHintHopDecodeErrorZ.ts b/ts/structs/Result_RouteHintHopDecodeErrorZ.ts
new file mode 100644 (file)
index 0000000..e6f39c6
--- /dev/null
@@ -0,0 +1,58 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+public class Result_RouteHintHopDecodeErrorZ extends CommonBase {
+       private Result_RouteHintHopDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteHintHopDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteHintHopDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteHintHopDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteHintHopDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteHintHopDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteHintHopDecodeErrorZ_OK extends Result_RouteHintHopDecodeErrorZ {
+               public final RouteHintHop res;
+               private Result_RouteHintHopDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number res = bindings.LDKCResult_RouteHintHopDecodeErrorZ_get_ok(ptr);
+                       const res_hu_conv: RouteHintHop = new RouteHintHop(null, res);
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteHintHopDecodeErrorZ_Err extends Result_RouteHintHopDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteHintHopDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number err = bindings.LDKCResult_RouteHintHopDecodeErrorZ_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_RouteHintHopDecodeErrorZ constructor_ok(RouteHintHop o) {
+               number ret = bindings.CResult_RouteHintHopDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Result_RouteHintHopDecodeErrorZ constructor_err(DecodeError e) {
+               number ret = bindings.CResult_RouteHintHopDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_RouteHintHopDecodeErrorZ clone() {
+               number ret = bindings.CResult_RouteHintHopDecodeErrorZ_clone(this.ptr);
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/Result_RouteParametersDecodeErrorZ.ts b/ts/structs/Result_RouteParametersDecodeErrorZ.ts
new file mode 100644 (file)
index 0000000..8c8e18b
--- /dev/null
@@ -0,0 +1,58 @@
+
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+public class Result_RouteParametersDecodeErrorZ extends CommonBase {
+       private Result_RouteParametersDecodeErrorZ(Object _dummy, long ptr) { super(ptr); }
+       protected void finalize() throws Throwable {
+               if (ptr != 0) { bindings.CResult_RouteParametersDecodeErrorZ_free(ptr); } super.finalize();
+       }
+
+       static Result_RouteParametersDecodeErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteParametersDecodeErrorZ_result_ok(ptr)) {
+                       return new Result_RouteParametersDecodeErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteParametersDecodeErrorZ_Err(null, ptr);
+               }
+       }
+       public static final class Result_RouteParametersDecodeErrorZ_OK extends Result_RouteParametersDecodeErrorZ {
+               public final RouteParameters res;
+               private Result_RouteParametersDecodeErrorZ_OK(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number res = bindings.LDKCResult_RouteParametersDecodeErrorZ_get_ok(ptr);
+                       const res_hu_conv: RouteParameters = new RouteParameters(null, res);
+                       res_hu_conv.ptrs_to.add(this);
+                       this.res = res_hu_conv;
+               }
+       }
+
+       public static final class Result_RouteParametersDecodeErrorZ_Err extends Result_RouteParametersDecodeErrorZ {
+               public final DecodeError err;
+               private Result_RouteParametersDecodeErrorZ_Err(Object _dummy, long ptr) {
+                       super(_dummy, ptr);
+                       number err = bindings.LDKCResult_RouteParametersDecodeErrorZ_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_RouteParametersDecodeErrorZ constructor_ok(RouteParameters o) {
+               number ret = bindings.CResult_RouteParametersDecodeErrorZ_ok(o == null ? 0 : o.ptr & ~1);
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static Result_RouteParametersDecodeErrorZ constructor_err(DecodeError e) {
+               number ret = bindings.CResult_RouteParametersDecodeErrorZ_err(e == null ? 0 : e.ptr & ~1);
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_RouteParametersDecodeErrorZ clone() {
+               number ret = bindings.CResult_RouteParametersDecodeErrorZ_clone(this.ptr);
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
index 29394b34f8c9ab4641ad6974e05175fcfcc60f88..670190b8e256c7ec8e69eb738ad257a92c8b49fe 100644 (file)
@@ -43,8 +43,14 @@ public class Result_ShutdownScriptInvalidShutdownScriptZ extends CommonBase {
                return ret_hu_conv;
        }
 
-       public static Result_ShutdownScriptInvalidShutdownScriptZ constructor_err(Uint8Array e_script_arg) {
-               number ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_err(bindings.InvalidShutdownScript_new(e_script_arg));
+       public static Result_ShutdownScriptInvalidShutdownScriptZ constructor_err(InvalidShutdownScript e) {
+               number ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_err(e == null ? 0 : e.ptr & ~1);
+               Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public Result_ShutdownScriptInvalidShutdownScriptZ clone() {
+               number ret = bindings.CResult_ShutdownScriptInvalidShutdownScriptZ_clone(this.ptr);
                Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
diff --git a/ts/structs/RetryAttempts.ts b/ts/structs/RetryAttempts.ts
new file mode 100644 (file)
index 0000000..a01632d
--- /dev/null
@@ -0,0 +1,55 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class RetryAttempts extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.RetryAttempts_free(this.ptr);
+                    }
+                }
+       public number get_a() {
+               number ret = bindings.RetryAttempts_get_a(this.ptr);
+               return ret;
+       }
+
+       public void set_a(number val) {
+               bindings.RetryAttempts_set_a(this.ptr, val);
+       }
+
+       public static RetryAttempts constructor_new(number a_arg) {
+               number ret = bindings.RetryAttempts_new(a_arg);
+               const ret_hu_conv: RetryAttempts = new RetryAttempts(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public RetryAttempts clone() {
+               number ret = bindings.RetryAttempts_clone(this.ptr);
+               const ret_hu_conv: RetryAttempts = new RetryAttempts(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public boolean eq(RetryAttempts b) {
+               boolean ret = bindings.RetryAttempts_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+       public number hash() {
+               number ret = bindings.RetryAttempts_hash(this.ptr);
+               return ret;
+       }
+
+}
index 330985650786531827d60834305707b3295eeca1..e0810374ba42ea318173784204adf96372d1d865 100644 (file)
@@ -39,8 +39,19 @@ import * as bindings from '../bindings' // TODO: figure out location
                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);
        }
 
-       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);
+       public Payee get_payee() {
+               number ret = bindings.Route_get_payee(this.ptr);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public void set_payee(Payee val) {
+               bindings.Route_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
+       public static Route constructor_new(RouteHop[][] paths_arg, Payee payee_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, payee_arg == null ? 0 : payee_arg.ptr & ~1);
                const ret_hu_conv: Route = new Route(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index a63a6f28b9ee80d3605fd25bc821021b03531a62..dfd723259dc070f90945f3e6f34072f5a99c824f 100644 (file)
@@ -18,6 +18,29 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.RouteHint_free(this.ptr);
                     }
                 }
+       public RouteHintHop[] get_a() {
+               number[] ret = bindings.RouteHint_get_a(this.ptr);
+               RouteHintHop[] ret_conv_14_arr = new RouteHintHop[ret.length];
+               for (int o = 0; o < ret.length; o++) {
+                       number ret_conv_14 = ret[o];
+                       const ret_conv_14_hu_conv: RouteHintHop = new RouteHintHop(null, ret_conv_14);
+                       ret_conv_14_hu_conv.ptrs_to.add(this);
+                       ret_conv_14_arr[o] = ret_conv_14_hu_conv;
+               }
+               return ret_conv_14_arr;
+       }
+
+       public void set_a(RouteHintHop[] val) {
+               bindings.RouteHint_set_a(this.ptr, val != null ? Arrays.stream(val).map(val_conv_14 -> val_conv_14 == null ? 0 : val_conv_14.ptr & ~1).toArray(number[]::new) : null);
+       }
+
+       public static RouteHint constructor_new(RouteHintHop[] a_arg) {
+               number ret = bindings.RouteHint_new(a_arg != null ? Arrays.stream(a_arg).map(a_arg_conv_14 -> a_arg_conv_14 == null ? 0 : a_arg_conv_14.ptr & ~1).toArray(number[]::new) : null);
+               const ret_hu_conv: RouteHint = new RouteHint(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
        public RouteHint clone() {
                number ret = bindings.RouteHint_clone(this.ptr);
                const ret_hu_conv: RouteHint = new RouteHint(null, ret);
@@ -36,4 +59,15 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
+       public Uint8Array write() {
+               Uint8Array ret = bindings.RouteHint_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_RouteHintDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.RouteHint_read(ser);
+               Result_RouteHintDecodeErrorZ ret_hu_conv = Result_RouteHintDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
index 461b00ddd08f5b2a6466477ae287483858943f8d..dc25be939c4cfce29f38e340fd51729b78b9e3b9 100644 (file)
@@ -103,4 +103,15 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
+       public Uint8Array write() {
+               Uint8Array ret = bindings.RouteHintHop_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_RouteHintHopDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.RouteHintHop_read(ser);
+               Result_RouteHintHopDecodeErrorZ ret_hu_conv = Result_RouteHintHopDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
diff --git a/ts/structs/RouteParameters.ts b/ts/structs/RouteParameters.ts
new file mode 100644 (file)
index 0000000..fa67e17
--- /dev/null
@@ -0,0 +1,75 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class RouteParameters extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.RouteParameters_free(this.ptr);
+                    }
+                }
+       public Payee get_payee() {
+               number ret = bindings.RouteParameters_get_payee(this.ptr);
+               const ret_hu_conv: Payee = new Payee(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public void set_payee(Payee val) {
+               bindings.RouteParameters_set_payee(this.ptr, val == null ? 0 : val.ptr & ~1);
+       }
+
+       public number get_final_value_msat() {
+               number ret = bindings.RouteParameters_get_final_value_msat(this.ptr);
+               return ret;
+       }
+
+       public void set_final_value_msat(number val) {
+               bindings.RouteParameters_set_final_value_msat(this.ptr, val);
+       }
+
+       public number get_final_cltv_expiry_delta() {
+               number ret = bindings.RouteParameters_get_final_cltv_expiry_delta(this.ptr);
+               return ret;
+       }
+
+       public void set_final_cltv_expiry_delta(number val) {
+               bindings.RouteParameters_set_final_cltv_expiry_delta(this.ptr, val);
+       }
+
+       public static RouteParameters constructor_new(Payee payee_arg, number final_value_msat_arg, number final_cltv_expiry_delta_arg) {
+               number ret = bindings.RouteParameters_new(payee_arg == null ? 0 : payee_arg.ptr & ~1, final_value_msat_arg, final_cltv_expiry_delta_arg);
+               const ret_hu_conv: RouteParameters = new RouteParameters(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public RouteParameters clone() {
+               number ret = bindings.RouteParameters_clone(this.ptr);
+               const ret_hu_conv: RouteParameters = new RouteParameters(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.RouteParameters_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_RouteParametersDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.RouteParameters_read(ser);
+               Result_RouteParametersDecodeErrorZ ret_hu_conv = Result_RouteParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+}
diff --git a/ts/structs/Router.ts b/ts/structs/Router.ts
new file mode 100644 (file)
index 0000000..4b7dd59
--- /dev/null
@@ -0,0 +1,74 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export class Router extends CommonBase {
+
+                bindings_instance?: bindings.LDKRouter;
+
+                constructor(ptr?: number, arg?: bindings.LDKRouter) {
+                    if (Number.isFinite(ptr)) {
+                                       super(ptr);
+                                       this.bindings_instance = null;
+                                   } else {
+                                       // TODO: private constructor instantiation
+                                       super(bindings.LDKRouter_new(arg));
+                                       this.ptrs_to.push(arg);
+                                       
+                                   }
+                }
+
+                protected finalize() {
+                    if (this.ptr != 0) {
+                        bindings.Router_free(this.ptr);
+                    }
+                    super.finalize();
+                }
+
+                static new_impl(arg: RouterInterface): Router {
+                    const impl_holder: LDKRouterHolder = new LDKRouterHolder();
+                    let structImplementation = <bindings.LDKRouter>{
+                        // todo: in-line interface filling
+                        find_route (payer: Uint8Array, params: number, first_hops: number[], scorer: number): number {
+                                                       const params_hu_conv: RouteParameters = new RouteParameters(null, params);
+                                                       ChannelDetails[] first_hops_conv_16_arr = new ChannelDetails[first_hops.length];
+                               for (int q = 0; q < first_hops.length; q++) {
+                                       number first_hops_conv_16 = first_hops[q];
+                                       const first_hops_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, first_hops_conv_16);
+                                       first_hops_conv_16_hu_conv.ptrs_to.add(this);
+                                       first_hops_conv_16_arr[q] = first_hops_conv_16_hu_conv;
+                               }
+                                                       Score ret_hu_conv = new Score(null, scorer);
+                               ret_hu_conv.ptrs_to.add(this);
+                                                       Result_RouteLightningErrorZ ret = arg.find_route(payer, params_hu_conv, first_hops_conv_16_arr, ret_hu_conv);
+                               result: number = ret != null ? ret.ptr : 0;
+                               return result;
+                                               },
+
+                                               
+                    };
+                    impl_holder.held = new Router (null, structImplementation);
+                }
+            }
+
+            export interface RouterInterface {
+                find_route(payer: Uint8Array, params: RouteParameters, first_hops: ChannelDetails[], scorer: Score): Result_RouteLightningErrorZ;
+                               
+            }
+
+            class LDKRouterHolder {
+                held: Router;
+            }
+       public Result_RouteLightningErrorZ find_route(Uint8Array payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer) {
+               number ret = bindings.Router_find_route(this.ptr, payer, params == null ? 0 : params.ptr & ~1, 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, scorer == null ? 0 : scorer.ptr);
+               Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+               this.ptrs_to.add(params);
+               for (ChannelDetails first_hops_conv_16: first_hops) { this.ptrs_to.add(first_hops_conv_16); };
+               this.ptrs_to.add(scorer);
+               return ret_hu_conv;
+       }
+
+}
index 6372374a3b6decb5e1ddb9ba5da2fa5787843fde..9a86ae0efbf59bde4a51a39bb1154c8fd32535a5 100644 (file)
@@ -32,8 +32,26 @@ import * as bindings from '../bindings' // TODO: figure out location
                     const impl_holder: LDKScoreHolder = new LDKScoreHolder();
                     let structImplementation = <bindings.LDKScore>{
                         // todo: in-line interface filling
-                        channel_penalty_msat (short_channel_id: number): number {
-                                                       number ret = arg.channel_penalty_msat(short_channel_id);
+                        channel_penalty_msat (short_channel_id: number, source: number, target: number): number {
+                                                       const source_hu_conv: NodeId = new NodeId(null, source);
+                                                       const target_hu_conv: NodeId = new NodeId(null, target);
+                                                       number ret = arg.channel_penalty_msat(short_channel_id, source_hu_conv, target_hu_conv);
+                               return ret;
+                                               },
+
+                                               payment_path_failed (path: number[], short_channel_id: number): void {
+                                                       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;
+                               }
+                                                       arg.payment_path_failed(path_conv_10_arr, short_channel_id);
+                                               },
+
+                                               write (): Uint8Array {
+                                                       Uint8Array ret = arg.write();
                                return ret;
                                                },
 
@@ -44,15 +62,28 @@ import * as bindings from '../bindings' // TODO: figure out location
             }
 
             export interface ScoreInterface {
-                channel_penalty_msat(short_channel_id: number): number;
+                channel_penalty_msat(short_channel_id: number, source: NodeId, target: NodeId): number;
+                               payment_path_failed(path: RouteHop[], short_channel_id: number): void;
+                               write(): Uint8Array;
                                
             }
 
             class LDKScoreHolder {
                 held: Score;
             }
-       public number channel_penalty_msat(number short_channel_id) {
-               number ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id);
+       public number channel_penalty_msat(number short_channel_id, NodeId source, NodeId target) {
+               number ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, source == null ? 0 : source.ptr & ~1, target == null ? 0 : target.ptr & ~1);
+               this.ptrs_to.add(source);
+               this.ptrs_to.add(target);
+               return ret;
+       }
+
+       public void payment_path_failed(RouteHop[] path, number short_channel_id) {
+               bindings.Score_payment_path_failed(this.ptr, path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null, short_channel_id);
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.Score_write(this.ptr);
                return ret;
        }
 
index b60d103b7ddc77955cea189fcf0cdede7ec9ee90..4c63fa031eba6d5e1f9c2f38e8609d9da437a982 100644 (file)
@@ -18,8 +18,8 @@ import * as bindings from '../bindings' // TODO: figure out location
                         bindings.Scorer_free(this.ptr);
                     }
                 }
-       public static Scorer constructor_new(number base_penalty_msat) {
-               number ret = bindings.Scorer_new(base_penalty_msat);
+       public static Scorer constructor_new(number params_base_penalty_msat_arg, number params_failure_penalty_msat_arg, number params_failure_penalty_half_life_arg) {
+               number ret = bindings.Scorer_new(bindings.ScoringParameters_new(params_base_penalty_msat_arg, params_failure_penalty_msat_arg, params_failure_penalty_half_life_arg));
                const ret_hu_conv: Scorer = new Scorer(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
@@ -39,4 +39,15 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_hu_conv;
        }
 
+       public Uint8Array write() {
+               Uint8Array ret = bindings.Scorer_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_ScorerDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.Scorer_read(ser);
+               Result_ScorerDecodeErrorZ ret_hu_conv = Result_ScorerDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }
diff --git a/ts/structs/ScoringParameters.ts b/ts/structs/ScoringParameters.ts
new file mode 100644 (file)
index 0000000..edbe4bc
--- /dev/null
@@ -0,0 +1,73 @@
+
+            
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
+
+
+
+            export default class ScoringParameters extends CommonBase {
+                constructor(_dummy: object, ptr: number) {
+                    super(ptr);
+                }
+
+                
+                protected finalize() {
+                    super.finalize();
+
+                    if (this.ptr != 0) {
+                        bindings.ScoringParameters_free(this.ptr);
+                    }
+                }
+       public number get_base_penalty_msat() {
+               number ret = bindings.ScoringParameters_get_base_penalty_msat(this.ptr);
+               return ret;
+       }
+
+       public void set_base_penalty_msat(number val) {
+               bindings.ScoringParameters_set_base_penalty_msat(this.ptr, val);
+       }
+
+       public number get_failure_penalty_msat() {
+               number ret = bindings.ScoringParameters_get_failure_penalty_msat(this.ptr);
+               return ret;
+       }
+
+       public void set_failure_penalty_msat(number val) {
+               bindings.ScoringParameters_set_failure_penalty_msat(this.ptr, val);
+       }
+
+       public number get_failure_penalty_half_life() {
+               number ret = bindings.ScoringParameters_get_failure_penalty_half_life(this.ptr);
+               return ret;
+       }
+
+       public void set_failure_penalty_half_life(number val) {
+               bindings.ScoringParameters_set_failure_penalty_half_life(this.ptr, val);
+       }
+
+       public static ScoringParameters constructor_new(number base_penalty_msat_arg, number failure_penalty_msat_arg, number failure_penalty_half_life_arg) {
+               number ret = bindings.ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
+               const ret_hu_conv: ScoringParameters = new ScoringParameters(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+       public Uint8Array write() {
+               Uint8Array ret = bindings.ScoringParameters_write(this.ptr);
+               return ret;
+       }
+
+       public static Result_ScoringParametersDecodeErrorZ constructor_read(Uint8Array ser) {
+               number ret = bindings.ScoringParameters_read(ser);
+               Result_ScoringParametersDecodeErrorZ ret_hu_conv = Result_ScoringParametersDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       public static ScoringParameters constructor_default() {
+               number ret = bindings.ScoringParameters_default();
+               const ret_hu_conv: ScoringParameters = new ScoringParameters(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
+       }
+
+}
index c4759b19655d28e762a975501ced4c889f8faacf..5f4d48d53b6c967bc9664898790467d996fbd425 100644 (file)
@@ -23,11 +23,9 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret;
        }
 
-       public PaymentId get_b() {
-               number ret = bindings.C2Tuple_PaymentHashPaymentIdZ_get_b(this.ptr);
-               const ret_hu_conv: PaymentId = new PaymentId(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
+       public Uint8Array get_b() {
+               Uint8Array ret = bindings.C2Tuple_PaymentHashPaymentIdZ_get_b(this.ptr);
+               return ret;
        }
 
        public TwoTuple_PaymentHashPaymentIdZ clone() {
@@ -37,8 +35,8 @@ import * as bindings from '../bindings' // TODO: figure out location
                return ret_hu_conv;
        }
 
-       public static TwoTuple_PaymentHashPaymentIdZ constructor_new(Uint8Array a, PaymentId b) {
-               number ret = bindings.C2Tuple_PaymentHashPaymentIdZ_new(a, b == null ? 0 : b.ptr & ~1);
+       public static TwoTuple_PaymentHashPaymentIdZ constructor_new(Uint8Array a, Uint8Array b) {
+               number ret = bindings.C2Tuple_PaymentHashPaymentIdZ_new(a, b);
                TwoTuple_PaymentHashPaymentIdZ ret_hu_conv = new TwoTuple_PaymentHashPaymentIdZ(null, ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
index d1faeb048d2b389c8237638f11aab96e1bb6d016..474fa4065f8f315ea2fd9c9405cce2d1d0c973b4 100644 (file)
                return ret;
        }
 
-       public static Result_RouteLightningErrorZ constructor_get_keysend_route(Uint8Array our_node_pubkey, NetworkGraph network, Uint8Array payee, ChannelDetails[] first_hops, RouteHint[] last_hops, number final_value_msat, number final_cltv, Logger logger, Score scorer) {
-               number ret = bindings.get_keysend_route(our_node_pubkey, 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, scorer == null ? 0 : scorer.ptr);
-               Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(network);
-               for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
-               ret_hu_conv.ptrs_to.add(logger);
-               ret_hu_conv.ptrs_to.add(scorer);
-               return ret_hu_conv;
-       }
-
-       public static Result_RouteLightningErrorZ constructor_get_route(Uint8Array our_node_pubkey, NetworkGraph network, Uint8Array payee, InvoiceFeatures payee_features, ChannelDetails[] first_hops, RouteHint[] last_hops, number final_value_msat, number final_cltv, Logger logger, Score scorer) {
-               number ret = bindings.get_route(our_node_pubkey, network == null ? 0 : network.ptr & ~1, payee, payee_features == null ? 0 : payee_features.ptr & ~1, 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, scorer == null ? 0 : scorer.ptr);
+       public static Result_RouteLightningErrorZ constructor_find_route(Uint8Array our_node_pubkey, RouteParameters params, NetworkGraph network, ChannelDetails[] first_hops, Logger logger, Score scorer) {
+               number ret = bindings.find_route(our_node_pubkey, params == null ? 0 : params.ptr & ~1, network == null ? 0 : network.ptr & ~1, 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, logger == null ? 0 : logger.ptr, scorer == null ? 0 : scorer.ptr);
                Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(params);
                ret_hu_conv.ptrs_to.add(network);
                for (ChannelDetails first_hops_conv_16: first_hops) { ret_hu_conv.ptrs_to.add(first_hops_conv_16); };
                ret_hu_conv.ptrs_to.add(logger);
index 84b27c5723a66521d7f737ac486313b1aac52cb2..54159d8d85099d3c0db71e0710dd7194d5618c2f 100644 (file)
@@ -120,9 +120,10 @@ void *malloc(size_t size);
 void free(void *ptr);
 
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); }
+#define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
+#define CHECK_ACCESS(p)
 """
         else:
             self.c_file_pfx = self.c_file_pfx + """
@@ -174,11 +175,21 @@ static void alloc_freed(void* ptr) {
        __real_free(it);
 }
 static void FREE(void* ptr) {
-       if ((unsigned long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
+       if ((unsigned long)ptr <= 4096) return; // Rust loves to create pointers to the NULL page for dummys
        alloc_freed(ptr);
        __real_free(ptr);
 }
 
+static void CHECK_ACCESS(void* ptr) {
+       allocation* it = allocation_ll;
+       while (it->ptr != ptr) {
+               it = it->next;
+               if (it == NULL) {
+                       return; // addrsan should catch malloc-unknown and print more info than we have
+               }
+       }
+}
+
 void* __wrap_malloc(size_t len) {
        void* res = __real_malloc(len);
        new_allocation(res, "malloc call");